author | ar <ar> | 2005-01-21 19:56:15 (UTC) |
---|---|---|
committer | ar <ar> | 2005-01-21 19:56:15 (UTC) |
commit | cd51d382be50bc021739395309e23760f1619759 (patch) (side-by-side diff) | |
tree | e76155f772df7faea5fcf38667c6da8c916208db | |
parent | fdc37fbd908472e28735a8f0b01e3e66a43535e0 (diff) | |
download | opie-cd51d382be50bc021739395309e23760f1619759.zip opie-cd51d382be50bc021739395309e23760f1619759.tar.gz opie-cd51d382be50bc021739395309e23760f1619759.tar.bz2 |
- make opie compilable against qte 2.3.10 snapshot
check QT_VERSION against 0x030000 instead of 300
26 files changed, 45 insertions, 45 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index 5171bf1..bee58e7 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp @@ -1,512 +1,512 @@ /* ------------------------------------------------------------------------ */ /* */ /* [TEWidget.C] Terminal Emulation Widget */ /* */ /* ------------------------------------------------------------------------ */ /* */ /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ /* */ /* This file is part of Konsole - an X terminal for KDE */ /* */ /* ------------------------------------------------------------------------ */ /* */ /* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ /*! \class TEWidget \brief Visible screen contents This class is responsible to map the `image' of a terminal emulation to the display. All the dependency of the emulation to a specific GUI or toolkit is localized here. Further, this widget has no knowledge about being part of an emulation, it simply work within the terminal emulation framework by exposing size and key events and by being ordered to show a new image. <ul> <li> The internal image has the size of the widget (evtl. rounded up) <li> The external image used in setImage can have any size. <li> (internally) the external image is simply copied to the internal when a setImage happens. During a resizeEvent no painting is done a paintEvent is expected to follow anyway. </ul> \sa TEScreen \sa Emulation */ /* FIXME: - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent - 'font_a' not used in mouse events - add destructor */ /* TODO - evtl. be sensitive to `paletteChange' while using default colors. - set different 'rounding' styles? I.e. have a mode to show clipped chars? */ // #include "config.h" #include "TEWidget.h" #include "session.h" #include <qpe/config.h> #if !(QT_NO_COP) #include <qpe/qcopenvelope_qws.h> #endif #include <qclipboard.h> #ifndef QT_NO_DRAGANDDROP #include <qdragobject.h> #include <qfile.h> #endif #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <sys/stat.h> #include <sys/types.h> #include <signal.h> #include <assert.h> // #include "TEWidget.moc" //#include <kapp.h> //#include <kcursor.h> //#include <kurl.h> //#include <kdebug.h> //#include <klocale.h> #define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) #define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } #define loc(X,Y) ((Y)*columns+(X)) //FIXME: the rim should normally be 1, 0 only when running in full screen mode. #define rimX 0 // left/right rim width #define rimY 0 // top/bottom rim high #define SCRWIDTH 16 // width of the scrollbar #define yMouseScroll 1 // scroll increment used when dragging selection at top/bottom of window. /* ------------------------------------------------------------------------- */ /* */ /* Colors */ /* */ /* ------------------------------------------------------------------------- */ //FIXME: the default color table is in session.C now. // We need a way to get rid of this one, here. static const ColorEntry base_color_table[TABLE_COLORS] = // The following are almost IBM standard color codes, with some slight // gamma correction for the dim colors to compensate for bright X screens. // It contains the 8 ansiterm/xterm colors in 2 intensities. { // Fixme: could add faint colors here, also. // normal ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White // intensiv ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) }; /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) Code 0 1 2 3 4 5 6 7 ----------- ------- ------- ------- ------- ------- ------- ------- ------- ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White */ QColor TEWidget::getDefaultBackColor() { return color_table[DEFAULT_BACK_COLOR].color; } const ColorEntry* TEWidget::getColorTable() const { return color_table; } const ColorEntry* TEWidget::getdefaultColorTable() const { return base_color_table; } const QPixmap *TEWidget::backgroundPixmap() { static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); const QPixmap *pm = bg; return pm; } void TEWidget::setColorTable(const ColorEntry table[]) { for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; const QPixmap* pm = backgroundPixmap(); if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); update(); } //FIXME: add backgroundPixmapChanged. /* ------------------------------------------------------------------------- */ /* */ /* Font */ /* */ /* ------------------------------------------------------------------------- */ /* The VT100 has 32 special graphical characters. The usual vt100 extended xterm fonts have these at 0x00..0x1f. QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals come in here as proper unicode characters. We treat non-iso10646 fonts as VT100 extended and do the requiered mapping from unicode to 0x00..0x1f. The remaining translation is then left to the QCodec. */ // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. unsigned short vt100_graphics[32] = { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 }; static QChar vt100extended(QChar c) { switch (c.unicode()) { case 0x25c6 : return 1; case 0x2592 : return 2; case 0x2409 : return 3; case 0x240c : return 4; case 0x240d : return 5; case 0x240a : return 6; case 0x00b0 : return 7; case 0x00b1 : return 8; case 0x2424 : return 9; case 0x240b : return 10; case 0x2518 : return 11; case 0x2510 : return 12; case 0x250c : return 13; case 0x2514 : return 14; case 0x253c : return 15; case 0xf800 : return 16; case 0xf801 : return 17; case 0x2500 : return 18; case 0xf803 : return 19; case 0xf804 : return 20; case 0x251c : return 21; case 0x2524 : return 22; case 0x2534 : return 23; case 0x252c : return 24; case 0x2502 : return 25; case 0x2264 : return 26; case 0x2265 : return 27; case 0x03c0 : return 28; case 0x2260 : return 29; case 0x00a3 : return 30; case 0x00b7 : return 31; } return c; } static QChar identicalMap(QChar c) { return c; } void TEWidget::fontChange(const QFont &) { QFontMetrics fm(font()); font_h = fm.height(); // font_w = fm.maxWidth(); font_w = fm.width("m"); font_a = fm.ascent(); printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, fm.maxWidth(), font_w, font_a); //printf("font_h: %d\n",font_h); //printf("font_w: %d\n",font_w); //printf("font_a: %d\n",font_a); //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); //printf("rawname: %s\n",font().rawName().ascii()); fontMap = -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") ? vt100extended : #endif identicalMap; propagateSize(); update(); } void TEWidget::setVTFont(const QFont& f) { QFrame::setFont(f); } QFont TEWidget::getVTFont() { return font(); } void TEWidget::setFont(const QFont &) { // ignore font change request if not coming from konsole itself } /* ------------------------------------------------------------------------- */ /* */ /* Constructor / Destructor */ /* */ /* ------------------------------------------------------------------------- */ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) { #ifndef QT_NO_CLIPBOARD cb = QApplication::clipboard(); QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), this, SLOT(onClearSelection()) ); #endif scrollbar = new QScrollBar(this); scrollbar->setCursor( arrowCursor ); connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); hScrollbar = new QScrollBar(this); hScrollbar->setCursor( arrowCursor ); hScrollbar->setOrientation(QScrollBar::Horizontal); // hScrollbar->setMaximumHeight(16); connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); Config cfg( "Konsole" ); cfg.setGroup("ScrollBar"); switch( cfg.readNumEntry("Position",2)){ case 0: scrollLoc = SCRNONE; break; case 1: scrollLoc = SCRLEFT; break; case 2: scrollLoc = SCRRIGHT; break; }; useHorzScroll=cfg.readBoolEntry("HorzScroll",0); blinkT = new QTimer(this); connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); // blinking = FALSE; blinking = TRUE; resizing = FALSE; actSel = 0; image = 0; lines = 1; columns = 1; font_w = 1; font_h = 1; font_a = 1; word_selection_mode = FALSE; hposition = 0; vcolumns = 0; useBeep = true; setMouseMarks(TRUE); setVTFont( QFont("fixed") ); setColorTable(base_color_table); // init color table qApp->installEventFilter( this ); //FIXME: see below // KCursor::setAutoHideCursor( this, true ); // Init DnD //////////////////////////////////////////////////////////////// currentSession = NULL; // setAcceptDrops(true); // attempt // m_drop = new QPopupMenu(this); // m_drop->insertItem( QString("Paste"), 0); // m_drop->insertItem( QString("cd"), 1); // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); // we need focus so that the auto-hide cursor feature works setFocus(); setFocusPolicy( WheelFocus ); } //FIXME: make proper destructor // Here's a start (David) TEWidget::~TEWidget() { qApp->removeEventFilter( this ); if (image) free(image); } /* ------------------------------------------------------------------------- */ /* */ /* Display Operations */ /* */ /* ------------------------------------------------------------------------- */ /*! attributed string draw primitive */ void TEWidget::drawAttrStr(QPainter &paint, QRect rect, QString& str, ca attr, BOOL pm, BOOL clear) { if (pm && color_table[attr.b].transparent) { paint.setBackgroundMode( TransparentMode ); if (clear) erase(rect); } else { if (blinking) paint.fillRect(rect, color_table[attr.b].color); else { paint.setBackgroundMode( OpaqueMode ); paint.setBackgroundColor( color_table[attr.b].color ); } } if (color_table[attr.f].bold) paint.setPen(QColor( 0x8F, 0x00, 0x00 )); else paint.setPen(color_table[attr.f].color); paint.drawText(rect.x(),rect.y()+font_a, str); if (attr.r & RE_UNDERLINE) paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); } /*! The image can only be set completely. The size of the new image may or may not match the size of the widget. */ void TEWidget::setImage(const ca* const newimg, int lines, int columns) { int y,x,len; const QPixmap* pm = backgroundPixmap(); QPainter paint; setUpdatesEnabled(FALSE); paint.begin( this ); HCNT("setImage"); QPoint tL = contentsRect().topLeft(); int tLx = tL.x(); int tLy = tL.y(); hasBlinker = FALSE; int cf = -1; // undefined int cb = -1; // undefined int cr = -1; // undefined int lins = QMIN(this->lines, QMAX(0,lines )); int cols = QMIN(this->columns,QMAX(0,columns)); QChar *disstrU = new QChar[cols]; for (y = 0; y < lins; y++) { const ca* lcl = &image[y*this->columns]; const ca* const ext = &newimg[y*columns]; if (!resizing) // not while resizing, we're expecting a paintEvent for (x = 0; x < cols; x++) { hasBlinker |= (ext[x].r & RE_BLINK); if (ext[x] != lcl[x]) { cr = ext[x].r; cb = ext[x].b; if (ext[x].f != cf) cf = ext[x].f; int lln = cols - x; disstrU[0] = fontMap(ext[x+0].c); for (len = 1; len < lln; len++) { if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) break; disstrU[len] = fontMap(ext[x+len].c); } QString unistr(disstrU,len); drawAttrStr(paint, QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), unistr, ext[x], pm != NULL, true); x += len - 1; } } // finally, make `image' become `newimg'. memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); } drawFrame( &paint ); paint.end(); setUpdatesEnabled(TRUE); if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } delete [] disstrU; } // paint Event //////////////////////////////////////////////////// /*! The difference of this routine vs. the `setImage' is, that the drawing does not include a difference analysis between the old and the new image. Instead, the internal image is used and the painting bound by the PaintEvent box. */ void TEWidget::paintEvent( QPaintEvent* pe ) { //{ static int cnt = 0; printf("paint %d\n",cnt++); } const QPixmap* pm = backgroundPixmap(); QPainter paint; setUpdatesEnabled(FALSE); paint.begin( this ); paint.setBackgroundMode( TransparentMode ); HCNT("paintEvent"); // Note that the actual widget size can be slightly larger // that the image (the size is truncated towards the smaller // number of characters in `resizeEvent'. The paint rectangle // can thus be larger than the image, but less then the size // of one character. QRect rect = pe->rect().intersect(contentsRect()); QPoint tL = contentsRect().topLeft(); int tLx = tL.x(); int tLy = tL.y(); int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); /* printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, rect.left(), rect.right(), rect.top(), rect.bottom()); */ diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index cabeb20..c7273c5 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp @@ -1,304 +1,304 @@ /********************************************************************** // textedit.cpp ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Opie Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** **********************************************************************/ // changes added by L. J. Potter Sun 02-17-2002 21:31:31 #include "textedit.h" #include "filePermissions.h" /* OPIE */ #include <opie2/odebug.h> #include <opie2/ofileselector.h> #include <opie2/ofiledialog.h> #include <opie2/ofontselector.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> /* QT */ #include <qmenubar.h> #include <qtoolbar.h> #include <qtextstream.h> #include <qclipboard.h> #include <qaction.h> #include <qlineedit.h> #include <qmessagebox.h> #include <qlayout.h> #include <qtimer.h> #include <qdir.h> /* STD */ #include <unistd.h> #include <sys/stat.h> #include <stdlib.h> //getenv using namespace Opie::Core; using namespace Opie::Ui; -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 class QpeEditor : public QMultiLineEdit { public: QpeEditor( QWidget *parent, const char * name = 0 ) : QMultiLineEdit( parent, name ) { clearTableFlags(); setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); } void find( const QString &txt, bool caseSensitive, bool backwards ); protected: bool markIt; int line1, line2, col1, col2; void mousePressEvent( QMouseEvent * ); void mouseReleaseEvent( QMouseEvent * ); //public slots: /* signals: void notFound(); void searchWrapped(); */ private: }; void QpeEditor::mousePressEvent( QMouseEvent *e ) { switch(e->button()) { case RightButton: { //rediculous workaround for qt popup menu //and the hold right click mechanism this->setSelection( line1, col1, line2, col2); QMultiLineEdit::mousePressEvent( e ); markIt = false; } break; default: { if(!markIt) { int line, col; this->getCursorPosition(&line, &col); line1=line2=line; col1=col2=col; } QMultiLineEdit::mousePressEvent( e ); } break; }; } void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { if(this->hasMarkedText()) { markIt = true; this->getMarkedRegion( &line1, &col1, &line2, & col2 ); } else { markIt = false; } } void QpeEditor::find ( const QString &txt, bool caseSensitive, bool backwards ) { static bool wrap = false; int line, col; if ( wrap ) { if ( !backwards ) line = col = 0; wrap = false; // emit searchWrapped(); } else { getCursorPosition( &line, &col ); } //ignore backwards for now.... if ( !backwards ) { for ( ; ; ) { if ( line >= numLines() ) { wrap = true; //emit notFound(); break; } int findCol = getString( line )->find( txt, col, caseSensitive ); if ( findCol >= 0 ) { setCursorPosition( line, findCol, false ); col = findCol + txt.length(); setCursorPosition( line, col, true ); //found = true; break; } line++; col = 0; } } } #else #error "Must make a QpeEditor that inherits QTextEdit" #endif static const int nfontsizes = 6; static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) : QMainWindow( parent, name, f ), bFromDocView( false ) { doc = 0; edited=false; fromSetDocument=false; setToolBarsMovable( false ); connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); channel = new QCopChannel( "QPE/Application/textedit", this ); connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); setIcon( Resource::loadPixmap( "TextEditor" ) ); QToolBar *bar = new QToolBar( this ); bar->setHorizontalStretchable( true ); menu = bar; QMenuBar *mb = new QMenuBar( bar ); QPopupMenu *file = new QPopupMenu( this ); QPopupMenu *edit = new QPopupMenu( this ); QPopupMenu *advancedMenu = new QPopupMenu(this); font = new QPopupMenu( this ); bar = new QToolBar( this ); editBar = bar; QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); // a->addTo( bar ); a->addTo( file ); a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); a->addTo( bar ); a->addTo( file ); a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); file->insertSeparator(); a->addTo( bar ); a->addTo( file ); a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); a->addTo( file ); a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); a->addTo( editBar ); a->addTo( edit ); a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); a->addTo( editBar ); a->addTo( edit ); a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); a->addTo( editBar ); a->addTo( edit ); #ifndef QT_NO_CLIPBOARD a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); a->addTo( edit ); #endif a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); edit->insertSeparator(); a->addTo( edit ); a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); a->addTo( bar ); a->addTo( edit ); zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); zin->addTo( font ); zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); zout->addTo( font ); font->insertSeparator(); font->insertItem(tr("Font"), this, SLOT(changeFont()) ); font->insertSeparator(); font->insertItem(tr("Advanced Features"), advancedMenu); QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); wa->setToggleAction(true); wa->addTo( advancedMenu); nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); nStart->setToggleAction(true); nStart->addTo( advancedMenu ); nStart->setEnabled(false); nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 ); connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) ); nAdvanced->setToggleAction(true); nAdvanced->addTo( advancedMenu ); desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 ); connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) ); desktopAction->setToggleAction(true); desktopAction->addTo( advancedMenu); filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 ); connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) ); filePermAction->setToggleAction(true); filePermAction->addTo( advancedMenu); searchBarAction = new QAction( tr("Search Bar Open"), QString::null, 0, this, 0 ); connect( searchBarAction, SIGNAL( toggled(bool) ), this, SLOT( setSearchBar(bool) ) ); diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp index 73c2cbe..ac24894 100644 --- a/core/opie-login/loginwindowimpl.cpp +++ b/core/opie-login/loginwindowimpl.cpp @@ -1,262 +1,262 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qpe/version.h> #include <qpushbutton.h> #include <qlayout.h> #include <qlineedit.h> #include <qtimer.h> #include <qcombobox.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qmessagebox.h> -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 #include <qgfx_qws.h> #endif #include <qwindowsystem_qws.h> #include <qpe/resource.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/config.h> #include <opie2/odevice.h> #include <stdio.h> #include <stdlib.h> #include "passworddialogimpl.h" #include "loginwindowimpl.h" #include "loginapplication.h" #include "inputmethods.h" using namespace Opie::Core; LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) { QPopupMenu *pop = new QPopupMenu ( this ); pop-> insertItem ( tr( "Restart" ), this, SLOT( restart())); pop-> insertItem ( tr( "Quit" ), this, SLOT( quit())); m_menu-> setPopup ( pop ); QCopChannel *channel = new QCopChannel ( "QPE/TaskBar", this ); connect ( channel, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( receive(const QCString&,const QByteArray&))); QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); m_input = new InputMethods ( m_taskbar ); connect ( m_input, SIGNAL( inputToggled(bool)), this, SLOT( calcMaxWindowRect())); lay-> addWidget ( m_input ); lay-> addStretch ( 10 ); setActiveWindow ( ); m_password-> setFocus ( ); m_user-> insertStringList ( lApp-> allUsers ( )); //there is no point in displaying the IM for a zaurus if (ODevice::inst ( )-> series ( ) != Model_Zaurus){ QTimer::singleShot ( 0, this, SLOT( showIM())); } QString opiedir = ::getenv ( "OPIEDIR" ); QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); if ( !bgpix. isNull ( )) { setBackgroundPixmap ( bgpix ); m_caption-> setBackgroundPixmap ( bgpix); TextLabel1-> setBackgroundPixmap ( bgpix); TextLabel2-> setBackgroundPixmap ( bgpix); } // m_caption-> setText ( tr("<center>Welcome to OPIE %1</center><center>& %2 %3</center>"). arg(QPE_VERSION). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); Config cfg ( "opie-login" ); cfg. setGroup ( "General" ); QString last = cfg. readEntry ( "LastLogin" ); if ( !last. isEmpty ( )) m_user-> setEditText ( last ); calcMaxWindowRect ( ); if ( PasswordDialogImpl::needDialog() ) QTimer::singleShot(10, this, SLOT(showPasswordDialog()) ); } LoginWindowImpl::~LoginWindowImpl ( ) { } void LoginWindowImpl::receive ( const QCString &msg, const QByteArray &data ) { QDataStream stream ( data, IO_ReadOnly ); if ( msg == "hideInputMethod()" ) m_input-> hideInputMethod ( ); else if ( msg == "showInputMethod()" ) m_input-> showInputMethod ( ); else if ( msg == "reloadInputMethods()" ) m_input-> loadInputMethods ( ); } void LoginWindowImpl::calcMaxWindowRect ( ) { #ifdef Q_WS_QWS QRect wr; int displayWidth = qApp-> desktop ( )-> width ( ); QRect ir = m_input-> inputRect ( ); if ( ir.isValid() ) wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); else wr.setCoords( 0, 0, displayWidth-1, m_taskbar->y()-1 ); -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 wr = qt_screen-> mapToDevice ( wr, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); #endif QWSServer::setMaxWindowRect( wr ); #endif } void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) { switch ( e-> key ( )) { case HardKey_Suspend: suspend ( ); break; case HardKey_Backlight: backlight ( ); break; default: e-> ignore ( ); break; } LoginWindow::keyPressEvent ( e ); } void LoginWindowImpl::toggleEchoMode ( bool t ) { m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); } void LoginWindowImpl::showIM ( ) { m_input-> showInputMethod ( ); } void LoginWindowImpl::restart ( ) { qApp-> quit ( ); } void LoginWindowImpl::quit ( ) { lApp-> quitToConsole ( ); } void LoginWindowImpl::suspend ( ) { ODevice::inst ( )-> suspend ( ); QCopEnvelope e("QPE/System", "setBacklight(int)"); e << -3; // Force on } void LoginWindowImpl::backlight ( ) { QCopEnvelope e("QPE/System", "setBacklight(int)"); e << -2; // toggle } class WaitLogo : public QLabel { public: WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ) { QImage img = Resource::loadImage ( "launcher/new_wait" ); QPixmap pix; pix. convertFromImage ( img ); setPixmap ( pix ); setAlignment ( AlignCenter ); move ( 0, 0 ); resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( )); m_visible = false; show ( ); } virtual void showEvent ( QShowEvent *e ) { QLabel::showEvent ( e ); m_visible = true; } virtual void paintEvent ( QPaintEvent *e ) { QLabel::paintEvent ( e ); if ( m_visible ) qApp-> quit ( ); } private: bool m_visible; }; void LoginWindowImpl::login ( ) { const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); if ( !user || !user [0] ) return; if ( !pass ) pass = ""; if ( lApp-> checkPassword ( user, pass )) { Config cfg ( "opie-login" ); cfg. setGroup ( "General" ); cfg. writeEntry ( "LastLogin", user ); cfg. write ( ); lApp-> setLoginAs ( user ); // Draw a big wait icon, the image can be altered in later revisions m_input-> hideInputMethod ( ); new WaitLogo ( ); // WaitLogo::showEvent() calls qApp-> quit() } else { QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); m_password-> clear ( ); } } void LoginWindowImpl::showPasswordDialog() { PasswordDialogImpl dia( this ); dia.showMaximized(); dia.exec(); } diff --git a/freetype/fontfactoryttf_qws.h b/freetype/fontfactoryttf_qws.h index 208ab61..ff0fcfc 100644 --- a/freetype/fontfactoryttf_qws.h +++ b/freetype/fontfactoryttf_qws.h @@ -1,63 +1,63 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef FONTFACTORY_FT_H #define FONTFACTORY_FT_H #include <qfontmanager_qws.h> -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 # include <private/qfontdata_p.h> #else # include "qfontdata_p.h" #endif #ifdef QT_NO_FREETYPE extern "C" { #include <freetype/freetype.h> } // ascent, descent, width(ch), width(string), maxwidth? // leftbearing, rightbearing, minleftbearing,minrightbearing // leading class QFontFactoryFT : public QFontFactory { public: QFontFactoryFT(); virtual ~QFontFactoryFT(); QRenderedFont * get(const QFontDef &,QDiskFont *); virtual void load(QDiskFont *) const; virtual QString name(); private: friend class QRenderedFontFT; FT_Library library; }; #endif // QT_NO_FREETYPE #endif // QFONTFACTORY_FT_H diff --git a/libopie2/opieui/oseparator.cpp b/libopie2/opieui/oseparator.cpp index bbc4381..177368b 100644 --- a/libopie2/opieui/oseparator.cpp +++ b/libopie2/opieui/oseparator.cpp @@ -1,129 +1,129 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* OPIE */ #include <opie2/odebug.h> #include <opie2/oseparator.h> /* QT */ using namespace Opie::Core; using namespace Opie::Ui; OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f) : QFrame(parent, name, f) { setLineWidth(1); setMidLineWidth(0); setOrientation( HLine ); } OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f) : QFrame(parent, name, f) { setLineWidth(1); setMidLineWidth(0); setOrientation( orientation ); } void OSeparator::setOrientation(int orientation) { switch(orientation) { case Vertical: case VLine: setFrameStyle( QFrame::VLine | QFrame::Sunken ); setMinimumSize(2, 0); break; default: owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl; case Horizontal: case HLine: setFrameStyle( QFrame::HLine | QFrame::Sunken ); setMinimumSize(0, 2); break; } } int OSeparator::orientation() const { if ( frameStyle() & VLine ) return VLine; if ( frameStyle() & HLine ) return HLine; return 0; } void OSeparator::drawFrame(QPainter *p) { QPoint p1, p2; QRect r = frameRect(); const QColorGroup & g = colorGroup(); if ( frameStyle() & HLine ) { p1 = QPoint( r.x(), r.height()/2 ); p2 = QPoint( r.x()+r.width(), p1.y() ); } else { p1 = QPoint( r.x()+r.width()/2, 0 ); p2 = QPoint( p1.x(), r.height() ); } -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 style().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, 1, midLineWidth() ); #else QStyleOption opt( lineWidth(), midLineWidth() ); style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g, QStyle::Style_Sunken, opt ); #endif } QSize OSeparator::sizeHint() const { if ( frameStyle() & VLine ) return QSize(2, 0); if ( frameStyle() & HLine ) return QSize(0, 2); return QSize(-1, -1); } diff --git a/libopie2/qt3/opieui/oeditlistbox.h b/libopie2/qt3/opieui/oeditlistbox.h index 63fab11..c9c207d 100644 --- a/libopie2/qt3/opieui/oeditlistbox.h +++ b/libopie2/qt3/opieui/oeditlistbox.h @@ -1,250 +1,250 @@ /* This file is part of the KDE libraries Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OEDITLISTBOX_H #define OEDITLISTBOX_H #include <qgroupbox.h> #include <qlistbox.h> class OLineEdit; class OComboBox; class QPushButton; -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 enum StringComparisonMode { CaseSensitive = 0x00001, // 0 0001 BeginsWith = 0x00002, // 0 0010 EndsWith = 0x00004, // 0 0100 Contains = 0x00008, // 0 1000 ExactMatch = 0x00010 // 1 0000 }; #endif class OEditListBoxPrivate; /** * An editable listbox * * This class provides a editable listbox ;-), this means * a listbox which is accompanied by a line edit to enter new * items into the listbox and pushbuttons to add and remove * items from the listbox and two buttons to move items up and down. */ class OEditListBox : public QGroupBox { Q_OBJECT public: /// @since 3.1 class CustomEditor { public: CustomEditor() : m_representationWidget( 0L ), m_lineEdit( 0L ) {} CustomEditor( QWidget *repWidget, OLineEdit *edit ) : m_representationWidget( repWidget ), m_lineEdit( edit ) {} CustomEditor( OComboBox *combo ); void setRepresentationWidget( QWidget *repWidget ) { m_representationWidget = repWidget; } void setLineEdit( OLineEdit *edit ) { m_lineEdit = edit; } virtual QWidget *representationWidget() const { return m_representationWidget; } virtual OLineEdit *lineEdit() const { return m_lineEdit; } protected: QWidget *m_representationWidget; OLineEdit *m_lineEdit; }; public: /** * Enumeration of the buttons, the listbox offers. Specify them in the * constructor in the buttons parameter. */ enum Button { Add = 1, Remove = 2, UpDown = 4, All = Add|Remove|UpDown }; /** * Create an editable listbox. * * If @p checkAtEntering is true, after every character you type * in the line edit OEditListBox will enable or disable * the Add-button, depending whether the current content of the * line edit is already in the listbox. Maybe this can become a * performance hit with large lists on slow machines. * If @p checkAtEntering is false, * it will be checked if you press the Add-button. It is not * possible to enter items twice into the listbox. */ OEditListBox(QWidget *parent = 0, const char *name = 0, bool checkAtEntering=false, int buttons = All ); /** * Create an editable listbox. * * The same as the other constructor, additionally it takes * @title, which will be the title of the frame around the listbox. */ OEditListBox(const QString& title, QWidget *parent = 0, const char *name = 0, bool checkAtEntering=false, int buttons = All ); /** * Another constructor, which allows to use a custom editing widget * instead of the standard OLineEdit widget. E.g. you can use a * @ref OURLRequester or a @ref OComboBox as input widget. The custom * editor must consist of a lineedit and optionally another widget that * is used as representation. A OComboBox or a OURLRequester have a * OLineEdit as child-widget for example, so the OComboBox is used as * the representation widget. * * @see OURLRequester::customEditor() * @since 3.1 */ OEditListBox( const QString& title, const CustomEditor &customEditor, QWidget *parent = 0, const char *name = 0, bool checkAtEntering = false, int buttons = All ); virtual ~OEditListBox(); /** * Return a pointer to the embedded QListBox. */ QListBox* listBox() const { return m_listBox; } /** * Return a pointer to the embedded QLineEdit. */ OLineEdit* lineEdit() const { return m_lineEdit; } /** * Return a pointer to the Add button */ QPushButton* addButton() const { return servNewButton; } /** * Return a pointer to the Remove button */ QPushButton* removeButton() const { return servRemoveButton; } /** * Return a pointer to the Up button */ QPushButton* upButton() const { return servUpButton; } /** * Return a pointer to the Down button */ QPushButton* downButton() const { return servDownButton; } /** * See @ref QListBox::count() */ int count() const { return int(m_listBox->count()); } /** * See @ref QListBox::insertStringList() */ void insertStringList(const QStringList& list, int index=-1); /** * See @ref QListBox::insertStringList() */ void insertStrList(const QStrList* list, int index=-1); /** * See @ref QListBox::insertStrList() */ void insertStrList(const QStrList& list, int index=-1); /** * See @ref QListBox::insertStrList() */ void insertStrList(const char ** list, int numStrings=-1, int index=-1); /** * See @ref QListBox::insertItem() */ void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);} /** * Clears both the listbox and the line edit. */ void clear(); /** * See @ref QListBox::text() */ QString text(int index) const { return m_listBox->text(index); } /** * See @ref QListBox::currentItem() */ int currentItem() const; /** * See @ref QListBox::currentText() */ QString currentText() const { return m_listBox->currentText(); } /** * @returns a stringlist of all items in the listbox */ QStringList items() const; signals: void changed(); /** * This signal is emitted when the user adds a new string to the list, * the parameter is the added string. * @since 3.2 */ void added( const QString & text ); /** * This signal is emitted when the user removes a string from the list, * the parameter is the removed string. * @since 3.2 */ void removed( const QString & text ); protected slots: //the names should be self-explaining void moveItemUp(); void moveItemDown(); void addItem(); void removeItem(); void enableMoveButtons(int index); void typedSomething(const QString& text); private: QListBox *m_listBox; QPushButton *servUpButton, *servDownButton; QPushButton *servNewButton, *servRemoveButton; OLineEdit *m_lineEdit; //this is called in both ctors, to avoid code duplication void init( bool checkAtEntering, int buttons, QWidget *representationWidget = 0L ); protected: virtual void virtual_hook( int id, void* data ); private: //our lovely private d-pointer OEditListBoxPrivate *d; }; #endif // OEDITLISTBOX diff --git a/libopie2/qt3/opieui/ojanuswidget.cpp b/libopie2/qt3/opieui/ojanuswidget.cpp index 063e393..8bdbc03 100644 --- a/libopie2/qt3/opieui/ojanuswidget.cpp +++ b/libopie2/qt3/opieui/ojanuswidget.cpp @@ -519,513 +519,513 @@ bool OJanusWidget::setSwallowedWidget( QWidget *widget ) { QObject *o = l->at(i); if( o->isWidgetType() ) { ((QWidget*)o)->hide(); } } // // Add new child or make default size // if( widget == 0 ) { gbox->addRowSpacing(0,100); gbox->addColSpacing(0,100); mSwallowPage->setMinimumSize(100,100); } else { if( widget->parent() != mSwallowPage ) { widget->reparent( mSwallowPage, 0, QPoint(0,0) ); } gbox->addWidget(widget, 0, 0 ); gbox->activate(); mSwallowPage->setMinimumSize( widget->minimumSize() ); } return( true ); } bool OJanusWidget::slotShowPage() { if( mValid == false ) { return( false ); } if( mFace == TreeList ) { QListViewItem *node = mTreeList->selectedItem(); if( node == 0 ) { return( false ); } QWidget *stackItem = mTreeListToPageStack[node]; return showPage(stackItem); } else if( mFace == IconList ) { QListBoxItem *node = mIconList->item( mIconList->currentItem() ); if( node == 0 ) { return( false ); } QWidget *stackItem = mIconListToPageStack[node]; return showPage(stackItem); } return( false ); } bool OJanusWidget::showPage( int index ) { if( mPageList == 0 || mValid == false ) { return( false ); } else { return showPage(mPageList->at(index)); } } bool OJanusWidget::showPage( QWidget *w ) { if( w == 0 || mValid == false ) { return( false ); } if( mFace == TreeList || mFace == IconList ) { mPageStack->raiseWidget( w ); mActivePageWidget = w; int index = mPageList->findRef( w ); mTitleLabel->setText( *mTitleList->at(index) ); if( mFace == TreeList ) { QMap<QListViewItem *, QWidget *>::Iterator it; for (it = mTreeListToPageStack.begin(); it != mTreeListToPageStack.end(); ++it){ QListViewItem *key = it.key(); QWidget *val = it.data(); if (val == w) { mTreeList->setSelected(key, true ); break; } } } else { QMap<QListBoxItem *, QWidget *>::Iterator it; for (it = mIconListToPageStack.begin(); it != mIconListToPageStack.end(); ++it){ QListBoxItem *key = it.key(); QWidget *val = it.data(); if (val == w) { mIconList->setSelected( key, true ); break; } } // // 2000-02-13 Espen Sand // Don't ask me why (because I don't know). If I select a page // with the mouse the page is not updated until it receives an // event. It seems this event get lost if the mouse is not moved // when released. The timer ensures the update // QTimer::singleShot( 0, mActivePageWidget, SLOT(update()) ); } } else if( mFace == Tabbed ) { mTabControl->showPage(w); mActivePageWidget = w; } else { return( false ); } return( true ); } int OJanusWidget::activePageIndex() const { if( mFace == TreeList) { QListViewItem *node = mTreeList->selectedItem(); if( node == 0 ) { return -1; } QWidget *stackItem = mTreeListToPageStack[node]; return mPageList->findRef(stackItem); } else if (mFace == IconList) { QListBoxItem *node = mIconList->item( mIconList->currentItem() ); if( node == 0 ) { return( false ); } QWidget *stackItem = mIconListToPageStack[node]; return mPageList->findRef(stackItem); } else if( mFace == Tabbed ) { QWidget *widget = mTabControl->currentPage(); return( widget == 0 ? -1 : mPageList->findRef( widget ) ); } else { return( -1 ); } } int OJanusWidget::pageIndex( QWidget *widget ) const { if( widget == 0 ) { return( -1 ); } else if( mFace == TreeList || mFace == IconList ) { return( mPageList->findRef( widget ) ); } else if( mFace == Tabbed ) { // // The user gets the real page widget with addVBoxPage(), addHBoxPage() // and addGridPage() but not with addPage() which returns a child of // the toplevel page. addPage() returns a QFrame so I check for that. // if( widget->isA("QFrame") ) { return( mPageList->findRef( widget->parentWidget() ) ); } else { return( mPageList->findRef( widget ) ); } } else { return( -1 ); } } void OJanusWidget::slotFontChanged() { #ifdef FIXME if ( mTitleLabel != 0 ) { mTitleLabel->setFont( KGlobalSettings::generalFont() ); QFont titleFont( mTitleLabel->font() ); titleFont.setBold( true ); mTitleLabel->setFont( titleFont ); } #endif if( mFace == IconList ) { QFont listFont( mIconList->font() ); listFont.setBold( true ); mIconList->setFont( listFont ); mIconList->invalidateHeight(); mIconList->invalidateWidth(); } } // makes the treelist behave like the list of kcontrol void OJanusWidget::slotItemClicked(QListViewItem *it) { if(it && (it->childCount()>0)) it->setOpen(!it->isOpen()); } void OJanusWidget::setFocus() { if( mValid == false ) { return; } if( mFace == TreeList ) { mTreeList->setFocus(); } if( mFace == IconList ) { mIconList->setFocus(); } else if( mFace == Tabbed ) { mTabControl->setFocus(); } else if( mFace == Swallow ) { mSwallowPage->setFocus(); } else if( mFace == Plain ) { mPlainPage->setFocus(); } } QSize OJanusWidget::minimumSizeHint() const { if( mFace == TreeList || mFace == IconList ) { QSize s1( ODialog::spacingHint(), ODialog::spacingHint()*2 ); QSize s2(0,0); QSize s3(0,0); QSize s4( mPageStack->sizeHint() ); if( mFace == TreeList ) { -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 s1.rwidth() += style().splitterWidth(); #else s1.rwidth() += style().pixelMetric( QStyle::PM_SplitterWidth ); #endif s2 = mTreeList->minimumSize(); } else { mIconList->updateMinimumHeight(); mIconList->updateWidth(); s2 = mIconList->minimumSize(); } if( mTitleLabel->isVisible() == true ) { s3 += mTitleLabel->sizeHint(); s3.rheight() += mTitleSep->minimumSize().height(); } // // Select the tallest item. It has only effect in IconList mode // int h1 = s1.rheight() + s3.rheight() + s4.height(); int h2 = QMAX( h1, s2.rheight() ); return( QSize( s1.width()+s2.width()+QMAX(s3.width(),s4.width()), h2 ) ); } else if( mFace == Tabbed ) { return( mTabControl->sizeHint() ); } else if( mFace == Swallow ) { return( mSwallowPage->minimumSize() ); } else if( mFace == Plain ) { return( mPlainPage->sizeHint() ); } else { return( QSize( 100, 100 ) ); // Should never happen though. } } QSize OJanusWidget::sizeHint() const { return( minimumSizeHint() ); } void OJanusWidget::setTreeListAutoResize( bool state ) { if( mFace == TreeList ) { mTreeListResizeMode = state == false ? QSplitter::KeepSize : QSplitter::Stretch; QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget()); splitter->setResizeMode( mTreeList, mTreeListResizeMode ); } } void OJanusWidget::setIconListAllVisible( bool state ) { if( mFace == IconList ) { mIconList->setShowAll( state ); } } void OJanusWidget::setShowIconsInTreeList( bool state ) { mShowIconsInTreeList = state; } void OJanusWidget::setRootIsDecorated( bool state ) { if( mFace == TreeList ) { mTreeList->setRootIsDecorated(state); } } void OJanusWidget::unfoldTreeList( bool persist ) { if( mFace == TreeList ) { if( persist ) connect( mTreeList, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( slotReopen(QListViewItem*) ) ); else disconnect( mTreeList, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( slotReopen(QListViewItem*) ) ); for( QListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() ) item->setOpen( true ); } } void OJanusWidget::showEvent( QShowEvent * ) { if( mFace == TreeList ) { QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget()); splitter->setResizeMode( mTreeList, mTreeListResizeMode ); } } // // 2000-13-02 Espen Sand // It should be obvious that this eventfilter must only be // be installed on the vertical scrollbar of the mIconList. // bool OJanusWidget::eventFilter( QObject *o, QEvent *e ) { if( e->type() == QEvent::Show ) { IconListItem *item = (IconListItem*)mIconList->item(0); if( item != 0 ) { int lw = item->width( mIconList ); int sw = mIconList->verticalScrollBar()->sizeHint().width(); mIconList->setFixedWidth( lw+sw+mIconList->frameWidth()*2 ); } } else if( e->type() == QEvent::Hide ) { IconListItem *item = (IconListItem*)mIconList->item(0); if( item != 0 ) { int lw = item->width( mIconList ); mIconList->setFixedWidth( lw+mIconList->frameWidth()*2 ); } } return QWidget::eventFilter( o, e ); } // // Code for the icon list box // OJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name, WFlags f ) :QListBox( parent, name, f ), mShowAll(false), mHeightValid(false), mWidthValid(false) { } void OJanusWidget::IconListBox::updateMinimumHeight() { if( mShowAll == true && mHeightValid == false ) { int h = frameWidth()*2; for( QListBoxItem *i = item(0); i != 0; i = i->next() ) { h += i->height( this ); } setMinimumHeight( h ); mHeightValid = true; } } void OJanusWidget::IconListBox::updateWidth() { if( mWidthValid == false ) { int maxWidth = 10; for( QListBoxItem *i = item(0); i != 0; i = i->next() ) { int w = ((IconListItem *)i)->width(this); maxWidth = QMAX( w, maxWidth ); } for( QListBoxItem *i = item(0); i != 0; i = i->next() ) { ((IconListItem *)i)->expandMinimumWidth( maxWidth ); } if( verticalScrollBar()->isVisible() ) { maxWidth += verticalScrollBar()->sizeHint().width(); } setFixedWidth( maxWidth + frameWidth()*2 ); mWidthValid = true; } } void OJanusWidget::IconListBox::invalidateHeight() { mHeightValid = false; } void OJanusWidget::IconListBox::invalidateWidth() { mWidthValid = false; } void OJanusWidget::IconListBox::setShowAll( bool showAll ) { mShowAll = showAll; mHeightValid = false; } OJanusWidget::IconListItem::IconListItem( QListBox *listbox, const QPixmap &pixmap, const QString &text ) : QListBoxItem( listbox ) { mPixmap = pixmap; if( mPixmap.isNull() == true ) { mPixmap = defaultPixmap(); } setText( text ); mMinimumWidth = 0; } int OJanusWidget::IconListItem::expandMinimumWidth( int width ) { mMinimumWidth = QMAX( mMinimumWidth, width ); return( mMinimumWidth ); } const QPixmap &OJanusWidget::IconListItem::defaultPixmap() { static QPixmap *pix=0; if( pix == 0 ) { pix = new QPixmap( 32, 32 ); QPainter p( pix ); p.eraseRect( 0, 0, pix->width(), pix->height() ); p.setPen( Qt::red ); p.drawRect ( 0, 0, pix->width(), pix->height() ); p.end(); QBitmap mask( pix->width(), pix->height(), true ); mask.fill( Qt::black ); p.begin( &mask ); p.setPen( Qt::white ); p.drawRect ( 0, 0, pix->width(), pix->height() ); p.end(); pix->setMask( mask ); diff --git a/library/lightstyle.cpp b/library/lightstyle.cpp index f18bdca..3bd1623 100644 --- a/library/lightstyle.cpp +++ b/library/lightstyle.cpp @@ -1,690 +1,690 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "lightstyle.h" -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 #define INCLUDE_MENUITEM_DEF #include "qmenubar.h" #include "qapplication.h" #include "qpainter.h" #include "qpalette.h" #include "qframe.h" #include "qpushbutton.h" #include "qdrawutil.h" #include "qscrollbar.h" #include "qtabbar.h" #include "qguardedptr.h" #include "qlayout.h" #include "qlineedit.h" class LightStylePrivate { public: LightStylePrivate() : hoverWidget(0), ref(1), savePalette(0) { } QGuardedPtr<QWidget> hoverWidget; QPalette oldPalette, hoverPalette; int ref; QPoint mousePos; QPalette *savePalette; }; static LightStylePrivate *singleton = 0; LightStyle::LightStyle() : QWindowsStyle() { if (! singleton) { singleton = new LightStylePrivate; QPalette pal = QApplication::palette(); singleton->oldPalette = pal; QColor bg = pal.color(QPalette::Active, QColorGroup::Background); QColor prelight; if ( (bg.red() + bg.green() + bg.blue()) / 3 > 128) prelight = pal.color(QPalette::Active, QColorGroup::Background).light(110); else prelight = pal.color(QPalette::Active, QColorGroup::Background).light(120); QColorGroup active2(pal.color(QPalette::Active, QColorGroup::Foreground), // foreground prelight, // button prelight.light(), // light prelight.dark(), // dark prelight.dark(120), // mid pal.color(QPalette::Active, QColorGroup::Text), // text pal.color(QPalette::Active, QColorGroup::BrightText), // bright text pal.color(QPalette::Active, QColorGroup::Base), // base bg); // background active2.setColor(QColorGroup::Highlight, pal.color(QPalette::Active, QColorGroup::Highlight)); singleton->hoverPalette = pal; singleton->hoverPalette.setActive(active2); singleton->hoverPalette.setInactive(active2); } else singleton->ref++; } LightStyle::~LightStyle() { if (singleton && singleton->ref-- <= 0) { delete singleton; singleton = 0; } } QSize LightStyle::scrollBarExtent() const { return QSize(12 + defaultFrameWidth(), 12 + defaultFrameWidth()); } int LightStyle::buttonDefaultIndicatorWidth() const { return 2; } int LightStyle::sliderThickness() const { return 16; } int LightStyle::sliderLength() const { return 13; } int LightStyle::buttonMargin() const { return 4; } QSize LightStyle::exclusiveIndicatorSize() const { return QSize(13, 13); } int LightStyle::defaultFrameWidth() const { return 2; } QSize LightStyle::indicatorSize() const { return QSize(13, 13); } void LightStyle::polish(QWidget *widget) { if (widget->inherits("QPushButton")) widget->installEventFilter(this); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (widget->inherits("QLineEdit")) { QLineEdit *lineedit = (QLineEdit *) widget; lineedit->setFrameShape(QFrame::StyledPanel); lineedit->setLineWidth(2); } #endif QWindowsStyle::polish(widget); } void LightStyle::unPolish(QWidget *widget) { if (widget->inherits("QPushButton")) widget->removeEventFilter(this); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (widget->inherits("QLineEdit")) { QLineEdit *lineedit = (QLineEdit *) widget; lineedit->setLineWidth(1); lineedit->setFrameShape(QFrame::WinPanel); } #endif QWindowsStyle::unPolish(widget); } void LightStyle::polish(QApplication *app) { QPalette pal = app->palette(); QColorGroup active(pal.color(QPalette::Active, QColorGroup::Foreground), // foreground pal.color(QPalette::Active, QColorGroup::Button), // button pal.color(QPalette::Active, QColorGroup::Background).light(), // light pal.color(QPalette::Active, QColorGroup::Background).dark(175), // dark pal.color(QPalette::Active, QColorGroup::Background).dark(110), // mid pal.color(QPalette::Active, QColorGroup::Text), // text pal.color(QPalette::Active, QColorGroup::BrightText), // bright text pal.color(QPalette::Active, QColorGroup::Base), // base pal.color(QPalette::Active, QColorGroup::Background)), // background disabled(pal.color(QPalette::Disabled, QColorGroup::Foreground), // foreground pal.color(QPalette::Disabled, QColorGroup::Button), // button pal.color(QPalette::Disabled, QColorGroup::Background).light(), // light pal.color(QPalette::Disabled, QColorGroup::Background).dark(), // dark pal.color(QPalette::Disabled, QColorGroup::Background).dark(110), // mid pal.color(QPalette::Disabled, QColorGroup::Text), // text pal.color(QPalette::Disabled, QColorGroup::BrightText), // bright text pal.color(QPalette::Disabled, QColorGroup::Base), // base pal.color(QPalette::Disabled, QColorGroup::Background)); // background active.setColor(QColorGroup::Highlight, pal.color(QPalette::Active, QColorGroup::Highlight)); disabled.setColor(QColorGroup::Highlight, pal.color(QPalette::Disabled, QColorGroup::Highlight)); active.setColor(QColorGroup::HighlightedText, pal.color(QPalette::Active, QColorGroup::HighlightedText)); disabled.setColor(QColorGroup::HighlightedText, pal.color(QPalette::Disabled, QColorGroup::HighlightedText)); pal.setActive(active); pal.setInactive(active); pal.setDisabled(disabled); singleton->oldPalette = pal; QColor bg = pal.color(QPalette::Active, QColorGroup::Background); QColor prelight; if ( (bg.red() + bg.green() + bg.blue()) / 3 > 128) prelight = pal.color(QPalette::Active, QColorGroup::Background).light(110); else prelight = pal.color(QPalette::Active, QColorGroup::Background).light(120); QColorGroup active2(pal.color(QPalette::Active, QColorGroup::Foreground), // foreground prelight, // button prelight.light(), // light prelight.dark(), // dark prelight.dark(120), // mid pal.color(QPalette::Active, QColorGroup::Text), // text pal.color(QPalette::Active, QColorGroup::BrightText), // bright text pal.color(QPalette::Active, QColorGroup::Base), // base bg); // background active2.setColor(QColorGroup::Highlight, pal.color(QPalette::Active, QColorGroup::Highlight)); singleton->hoverPalette = pal; singleton->hoverPalette.setActive(active2); singleton->hoverPalette.setInactive(active2); app->setPalette(pal); } void LightStyle::unPolish(QApplication *app) { app->setPalette(singleton->oldPalette); } void LightStyle::polishPopupMenu(QPopupMenu *menu) { menu->setMouseTracking(TRUE); } void LightStyle::drawPushButton(QPushButton *button, QPainter *p) { int x1, y1, x2, y2; button->rect().coords(&x1, &y1, &x2, &y2); if (button->isDefault()) { p->save(); p->setPen(button->palette().active().color(QColorGroup::Highlight)); p->setBrush(button->palette().active().brush(QColorGroup::Highlight)); p->drawRoundRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1, 15, 15); p->restore(); } if (button->isDefault() || button->autoDefault()) { x1 += buttonDefaultIndicatorWidth(); y1 += buttonDefaultIndicatorWidth(); x2 -= buttonDefaultIndicatorWidth(); y2 -= buttonDefaultIndicatorWidth(); if (button->isDefault()) { QPointArray pa(8); pa.setPoint(0, x1 + 2, y1 ); pa.setPoint(1, x2 - 1, y1 ); pa.setPoint(2, x2 + 1, y1 + 2); pa.setPoint(3, x2 + 1, y2 - 2); pa.setPoint(4, x2 - 2, y2 + 1); pa.setPoint(5, x1 + 2, y2 + 1); pa.setPoint(6, x1, y2 - 1); pa.setPoint(7, x1, y1 + 2); QRegion r(pa); p->setClipRegion(r); } } QBrush fill; if (button->isDown() || button->isOn()) fill = button->colorGroup().brush(QColorGroup::Mid); else fill = button->colorGroup().brush(QColorGroup::Button); if ( !button->isFlat() || button->isOn() || button->isDown() ) drawButton(p, x1, y1, x2 - x1 + 1, y2 - y1 + 1, button->colorGroup(), button->isOn() || button->isDown(), &fill); } void LightStyle::drawButton(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, const QBrush *fill) { p->save(); if ( fill ) p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill); else p->fillRect(x + 2, y + 2, w - 4, h - 4, QBrush(sunken ? g.mid() : g.button())); // frame p->setPen(g.dark()); p->drawLine(x, y + 2, x, y + h - 3); // left p->drawLine(x + 2, y, x + w - 3, y); // top p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom p->drawPoint(x + 1, y + 1); p->drawPoint(x + 1, y + h - 2); p->drawPoint(x + w - 2, y + 1); p->drawPoint(x + w - 2, y + h - 2); // bevel if (sunken) p->setPen(g.mid()); else p->setPen(g.light()); p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top if (sunken) p->setPen(g.light()); else p->setPen(g.mid()); p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1 p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1 p->restore(); } void LightStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, const QBrush *fill) { drawButton(p, x, y, w, h, g, sunken, fill); } void LightStyle::getButtonShift(int &x, int &y) const { x = y = 0; } void LightStyle::drawComboButton(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool, bool editable, bool, const QBrush *fill) { drawButton(p, x, y, w, h, g, FALSE, fill); if (editable) { QRect r = comboButtonRect(x, y, w, h); qDrawShadePanel(p, r.x() - 1, r.y() - 1, r.width() + defaultFrameWidth(), r.height() + defaultFrameWidth(), g, TRUE); } int indent = ((y + h) / 2) - 3; int xpos = x; -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if( QApplication::reverseLayout() ) xpos += indent; else #endif xpos += w - indent - 5; drawArrow(p, Qt::DownArrow, TRUE, xpos, indent, 5, 5, g, TRUE, fill); } QRect LightStyle::comboButtonRect( int x, int y, int w, int h ) const { QRect r(x + 3, y + 3, w - 6, h - 6); int indent = ((y + h) / 2) - 3; r.setRight(r.right() - indent - 10); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if( QApplication::reverseLayout() ) r.moveBy( indent + 10, 0 ); #endif return r; } QRect LightStyle::comboButtonFocusRect(int x, int y, int w, int h ) const { return comboButtonRect(x, y, w, h); } void LightStyle::drawPanel(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, int lw, const QBrush *fill) { if (lw >= 2) { if ( fill ) p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill); QPen oldpen = p->pen(); // frame p->setPen(g.dark()); p->drawLine(x, y + 2, x, y + h - 3); // left p->drawLine(x + 2, y, x + w - 3, y); // top p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom p->drawPoint(x + 1, y + 1); p->drawPoint(x + 1, y + h - 2); p->drawPoint(x + w - 2, y + 1); p->drawPoint(x + w - 2, y + h - 2); // bevel if (sunken) p->setPen(g.mid()); else p->setPen(g.light()); p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top if (sunken) p->setPen(g.light()); else p->setPen(g.mid()); p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1 p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1 // corners p->setPen(g.background()); p->drawLine(x, y, x + 1, y); p->drawLine(x, y + h - 1, x + 1, y + h - 1); p->drawLine(x + w - 2, y, x + w - 1, y); p->drawLine(x + w - 2, y + h - 1, x + w - 1, y + h - 1); p->drawPoint(x, y + 1); p->drawPoint(x, y + h - 2); p->drawPoint(x + w - 1, y + 1); p->drawPoint(x + w - 1, y + h - 2); p->setPen(oldpen); } else qDrawShadePanel(p, x, y, w, h, g, sunken, lw, fill); } void LightStyle::drawIndicator(QPainter *p, int x, int y ,int w, int h, const QColorGroup &g, int state, bool down, bool) { drawButton(p, x, y, w, h, g, TRUE, &g.brush(down ? QColorGroup::Mid : QColorGroup::Base)); p->save(); p->setPen(g.foreground()); if (state == QButton::NoChange) { p->drawLine(x + 3, y + h / 2, x + w - 4, y + h / 2); p->drawLine(x + 3, y + 1 + h / 2, x + w - 4, y + 1 + h / 2); p->drawLine(x + 3, y - 1 + h / 2, x + w - 4, y - 1 + h / 2); } else if (state == QButton::On) { p->drawLine(x + 4, y + 3, x + w - 4, y + h - 5); p->drawLine(x + 3, y + 3, x + w - 4, y + h - 4); p->drawLine(x + 3, y + 4, x + w - 5, y + h - 4); p->drawLine(x + 3, y + h - 5, x + w - 5, y + 3); p->drawLine(x + 3, y + h - 4, x + w - 4, y + 3); p->drawLine(x + 4, y + h - 4, x + w - 4, y + 4); } p->restore(); } void LightStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool on, bool down, bool) { p->save(); p->fillRect(x, y, w, h, g.brush(QColorGroup::Background)); p->setPen(g.dark()); p->drawArc(x, y, w, h, 0, 16*360); p->setPen(g.mid()); p->drawArc(x + 1, y + 1, w - 2, h - 2, 45*16, 180*16); p->setPen(g.light()); p->drawArc(x + 1, y + 1, w - 2, h - 2, 235*16, 180*16); p->setPen(down ? g.mid() : g.base()); p->setBrush(down ? g.mid() : g.base()); p->drawEllipse(x + 2, y + 2, w - 4, h - 4); if (on) { p->setBrush(g.foreground()); p->drawEllipse(x + 3, y + 3, w - x - 6, h - y - 6); } p->restore(); } #if 1 //copied from QPE style void LightStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) { #if 0 //We can't do this, because QTabBar::focusInEvent redraws the // tab label with the default font. QFont f = tb->font(); f.setBold( selected ); p->setFont( f ); #endif QRect r( t->rect() ); if ( tb->shape() == QTabBar::RoundedAbove ) { p->setPen( tb->colorGroup().light() ); p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); if ( r.left() == 0 ) p->drawPoint( tb->rect().bottomLeft() ); else { p->setPen( tb->colorGroup().light() ); p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); } if ( selected ) { p->setPen( tb->colorGroup().background() ); p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2), tb->colorGroup().brush( QColorGroup::Background )); } else { r.setRect( r.left() + 2, r.top() + 2, r.width() - 4, r.height() - 2 ); p->setPen( tb->colorGroup().button() ); p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3), tb->colorGroup().brush( QColorGroup::Button )); //do shading; will not work for pixmap brushes QColor bg = tb->colorGroup().button(); // int h,s,v; // bg.hsv( &h, &s, &v ); int n = r.height()/2; int dark = 100; for ( int i = 1; i < n; i++ ) { dark = (dark * (100+(i*15)/n) )/100; p->setPen( bg.dark( dark ) ); int y = r.bottom()-n+i; int x1 = r.left()+1; int x2 = r.right()-1; p->drawLine( x1, y, x2, y ); } } p->setPen( tb->colorGroup().light() ); p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 ); p->drawPoint( r.left()+1, r.top() + 1 ); p->drawLine( r.left()+2, r.top(), r.right() - 2, r.top() ); p->setPen( tb->colorGroup().dark() ); p->drawPoint( r.right() - 1, r.top() + 1 ); p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1); } else if ( tb->shape() == QTabBar::RoundedBelow ) { if ( selected ) { p->setPen( tb->colorGroup().background() ); p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2), tb->palette().normal().brush( QColorGroup::Background )); } else { p->setPen( tb->colorGroup().dark() ); p->drawLine( r.left(), r.top(), r.right(), r.top() ); r.setRect( r.left() + 2, r.top(), r.width() - 4, r.height() - 2 ); p->setPen( tb->colorGroup().button() ); p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3), tb->palette().normal().brush( QColorGroup::Button )); } p->setPen( tb->colorGroup().dark() ); p->drawLine( r.right(), r.top(), r.right(), r.bottom() - 2 ); p->drawPoint( r.right() - 1, r.bottom() - 1 ); p->drawLine( r.right() - 2, r.bottom(), r.left() + 2, r.bottom() ); p->setPen( tb->colorGroup().light() ); p->drawLine( r.left(), r.top()+1, r.left(), r.bottom() - 2 ); p->drawPoint( r.left() + 1, r.bottom() - 1 ); if ( r.left() == 0 ) p->drawPoint( tb->rect().topLeft() ); } else { QCommonStyle::drawTab( p, tb, t, selected ); } } #else void LightStyle::drawTab(QPainter *p, const QTabBar *tabbar, QTab *tab, bool selected) { p->save(); QColorGroup g = tabbar->colorGroup(); QRect fr(tab->r); fr.setLeft(fr.left() + 2); if (! selected) { if (tabbar->shape() == QTabBar::RoundedAbove || tabbar->shape() == QTabBar::TriangularAbove) { fr.setTop(fr.top() + 2); } else { fr.setBottom(fr.bottom() - 2); } } QRegion tabr(tab->r); QPointArray cliptri(4); cliptri.setPoint(0, fr.left(), fr.top()); cliptri.setPoint(1, fr.left(), fr.top() + 5); cliptri.setPoint(2, fr.left() + 5, fr.top()); cliptri.setPoint(3, fr.left(), fr.top()); QRegion trir(cliptri); p->setClipRegion(tabr - trir); p->setPen( NoPen ); p->setBrush(g.brush(selected ? QColorGroup::Background : QColorGroup::Mid)); diff --git a/library/lightstyle.h b/library/lightstyle.h index c377cc2..0392957 100644 --- a/library/lightstyle.h +++ b/library/lightstyle.h @@ -1,120 +1,120 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef LIGHTSTYLE_H #define LIGHTSTYLE_H #ifndef QT_H #include <qstyle.h> #include <qwindowsstyle.h> #endif // QT_H -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 #ifdef QT_PLUGIN_STYLE_LIGHT # define Q_EXPORT_STYLE_LIGHT #else # define Q_EXPORT_STYLE_LIGHT Q_EXPORT #endif // QT_PLUGIN_STYLE_LIGHT class Q_EXPORT_STYLE_LIGHT LightStyle : public QWindowsStyle { public: LightStyle(); virtual ~LightStyle(); void polish(QWidget *widget); void unPolish(QWidget*widget); void polish(QApplication *app); void unPolish(QApplication *app); void polishPopupMenu(QPopupMenu *menu); void drawPushButton(QPushButton *button, QPainter *p); void drawButton(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken = FALSE, const QBrush *fill = 0); void drawBevelButton(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken = FALSE, const QBrush *fill = 0); void getButtonShift(int &x, int &y) const; void drawComboButton(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken = FALSE, bool editable = FALSE, bool = TRUE, const QBrush *fill = 0); QRect comboButtonRect(int x, int y, int w, int h) const; QRect comboButtonFocusRect(int x, int y, int w, int h) const; void drawIndicator(QPainter *p, int x, int y ,int w, int h, const QColorGroup &g, int state, bool = FALSE, bool = TRUE); QSize indicatorSize() const; void drawExclusiveIndicator(QPainter *p, int x, int y ,int w, int h, const QColorGroup &g, bool on, bool = FALSE, bool = TRUE); QSize exclusiveIndicatorSize() const; void drawPanel(QPainter * p, int x, int y, int w, int h, const QColorGroup &g, bool sunken = FALSE, int = 1, const QBrush * = 0); void scrollBarMetrics( const QScrollBar *, int &, int &, int &, int & ) const; void drawScrollBarControls(QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl); QStyle::ScrollControl scrollBarPointOver(const QScrollBar *, int, const QPoint& p); void drawTab(QPainter *p, const QTabBar *tabbar, QTab *tab, bool selected); void drawSlider(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, Qt::Orientation orientation, bool, bool); void drawSliderGroove(QPainter *p, int x, int y, int w, int h, const QColorGroup& g, QCOORD, Qt::Orientation ); void drawToolBarHandle(QPainter *, const QRect &, Qt::Orientation, bool, const QColorGroup &, bool = FALSE ); QSize scrollBarExtent() const; int buttonDefaultIndicatorWidth() const; int buttonMargin() const; int sliderThickness() const; int sliderLength() const; int defaultFrameWidth() const; int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& ); int popupMenuItemHeight( bool checkable, QMenuItem*, const QFontMetrics& ); void drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, const QPalette& pal, bool act, bool enabled, int x, int y, int w, int h); protected: bool eventFilter(QObject *, QEvent *); }; #endif #endif // LIGHTSTYLE_H diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index af00f49..1c5ced3 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp @@ -1,319 +1,319 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** */ #define QTOPIA_INTERNAL_LANGLIST #include <stdlib.h> #include <unistd.h> #ifndef Q_OS_MACX #include <linux/limits.h> // needed for some toolchains (PATH_MAX) #endif #include <qfile.h> #include <qqueue.h> #ifdef Q_WS_QWS #ifndef QT_NO_COP #if QT_VERSION <= 231 #define private public #define sendLocally processEvent #include "qcopenvelope_qws.h" #undef private #else #include "qcopenvelope_qws.h" #endif #endif #include <qwindowsystem_qws.h> #endif #include <qtextstream.h> #include <qpalette.h> #include <qbuffer.h> #include <qptrdict.h> #include <qregexp.h> #include <qdir.h> #include <qlabel.h> #include <qdialog.h> #include <qdragobject.h> #include <qtextcodec.h> #include <qevent.h> #include <qtooltip.h> #include <qsignal.h> #include <qmainwindow.h> #include <qwidgetlist.h> #include <qpixmapcache.h> #if defined(Q_WS_QWS) && !defined(QT_NO_COP) #define QTOPIA_INTERNAL_INITAPP #include "qpeapplication.h" #include "qpestyle.h" #include "styleinterface.h" -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 #include <qstylefactory.h> #else #include <qplatinumstyle.h> #include <qwindowsstyle.h> #include <qmotifstyle.h> #include <qmotifplusstyle.h> #include "lightstyle.h" #include <qpe/qlibrary.h> #endif #include "global.h" #include "resource.h" #if QT_VERSION <= 230 && defined(QT_NO_CODECS) #include "qutfcodec.h" #endif #include "config.h" #include "network.h" #ifdef QWS #include "fontmanager.h" #include "fontdatabase.h" #endif #include "alarmserver.h" #include "applnk.h" #include "qpemenubar.h" #include "textcodecinterface.h" #include "imagecodecinterface.h" #include <qtopia/qpeglobal.h> #include <unistd.h> #include <sys/file.h> #include <sys/ioctl.h> #ifndef QT_NO_SOUND #include <sys/soundcard.h> #endif #include "qt_override_p.h" #include <backend/rohfeedback.h> static bool useBigPixmaps = 0; class HackWidget : public QWidget { public: bool needsOk() { return (getWState() & WState_Reserved1 ); } QRect normalGeometry() { return topData()->normalGeometry; }; }; class QPEApplicationData { public: QPEApplicationData ( ) : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), keep_running( true ), qcopQok( false ), fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), bigIconSize( 32 ), qpe_main_widget( 0 ) { Config cfg( "qpe" ); cfg.setGroup( "Appearance" ); useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); fontFamily = cfg.readEntry( "FontFamily", "Vera" ); fontSize = cfg.readNumEntry( "FontSize", 10 ); smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); #ifdef OPIE_WITHROHFEEDBACK RoH = 0; #endif } int presstimer; QWidget* presswidget; QPoint presspos; #ifdef OPIE_WITHROHFEEDBACK Opie::Internal::RoHFeedback *RoH; #endif bool rightpressed : 1; bool kbgrabbed : 1; bool notbusysent : 1; bool preloaded : 1; bool forceshow : 1; bool nomaximize : 1; bool keep_running : 1; bool qcopQok : 1; QCString fontFamily; int fontSize; int smallIconSize; int bigIconSize; QString appName; struct QCopRec { QCopRec( const QCString &ch, const QCString &msg, const QByteArray &d ) : channel( ch ), message( msg ), data( d ) { } QCString channel; QCString message; QByteArray data; }; QWidget* qpe_main_widget; QGuardedPtr<QWidget> lastraised; QQueue<QCopRec> qcopq; QString styleName; QString decorationName; void enqueueQCop( const QCString &ch, const QCString &msg, const QByteArray &data ) { qcopq.enqueue( new QCopRec( ch, msg, data ) ); } void sendQCopQ() { if (!qcopQok ) return; QCopRec * r; while((r=qcopq.dequeue())) { // remove from queue before sending... // event loop can come around again before getting // back from sendLocally #ifndef QT_NO_COP QCopChannel::sendLocally( r->channel, r->message, r->data ); #endif delete r; } } static void show_mx(QWidget* mw, bool nomaximize, QString &strName) { if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) { ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); } QPoint p; QSize s; bool max; if ( mw->isVisible() ) { if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { mw->resize(s); mw->move(p); } mw->raise(); } else { if ( mw->layout() && mw->inherits("QDialog") ) { if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { mw->resize(s); mw->move(p); if ( max && !nomaximize ) { mw->showMaximized(); } else { mw->show(); } } else { QPEApplication::showDialog((QDialog*)mw,nomaximize); } } else { if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { mw->resize(s); mw->move(p); } else { //no stored rectangle, make an estimation int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; mw->move( QMAX(x,0), QMAX(y,0) ); #ifdef Q_WS_QWS if ( !nomaximize ) mw->showMaximized(); #endif } if ( max && !nomaximize ) mw->showMaximized(); else mw->show(); } } } static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) { maximized = TRUE; // 350 is the trigger in qwsdefaultdecoration for providing a resize button if ( qApp->desktop()->width() <= 350 ) return FALSE; Config cfg( "qpe" ); cfg.setGroup("ApplicationPositions"); QString str = cfg.readEntry( app, QString::null ); QStringList l = QStringList::split(",", str); if ( l.count() == 5) { p.setX( l[0].toInt() ); p.setY( l[1].toInt() ); s.setWidth( l[2].toInt() ); s.setHeight( l[3].toInt() ); maximized = l[4].toInt(); return TRUE; } return FALSE; } static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) { #ifndef Q_WS_QWS QRect qt_maxWindowRect = qApp->desktop()->geometry(); #endif int maxX = qt_maxWindowRect.width(); int maxY = qt_maxWindowRect.height(); int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); // total window size is not allowed to be larger than desktop window size if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) return FALSE; if ( wWidth > maxX ) { s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); wWidth = maxX; } if ( wHeight > maxY ) { s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); wHeight = maxY; } // any smaller than this and the maximize/close/help buttons will be overlapping if ( wWidth < 80 || wHeight < 60 ) return FALSE; if ( p.x() < 0 ) p.setX(0); if ( p.y() < 0 ) p.setY(0); if ( p.x() + wWidth > maxX ) p.setX( maxX - wWidth ); if ( p.y() + wHeight > maxY ) p.setY( maxY - wHeight ); return TRUE; } @@ -1590,513 +1590,513 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data int t, v; stream >> t >> v; setTreble( t, v ); } else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> setTreble(); } else if ( msg == "getMarkedText()" ) { if ( type() == GuiServer ) { const ushort unicode = 'C'-'@'; const int scan = Key_C; qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); } } else if ( msg == "newChannel(QString)") { QString myChannel = "QPE/Application/" + d->appName; QString channel; stream >> channel; if (channel == myChannel) { processQCopFile(); d->sendQCopQ(); } } #endif } /*! \internal */ bool QPEApplication::raiseAppropriateWindow() { bool r=FALSE; // 1. Raise the main widget QWidget *top = d->qpe_main_widget; if ( !top ) top = mainWidget(); if ( top && d->keep_running ) { if ( top->isVisible() ) r = TRUE; else if (d->preloaded) { // We are preloaded and not visible.. pretend we just started.. #ifndef QT_NO_COP QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); e << d->appName; #endif } d->show_mx(top,d->nomaximize, d->appName); top->raise(); } QWidget *topm = activeModalWidget(); // 2. Raise any parentless widgets (except top and topm, as they // are raised before and after this loop). Order from most // recently raised as deepest to least recently as top, so // that repeated calls cycle through widgets. QWidgetList *list = topLevelWidgets(); if ( list ) { bool foundlast = FALSE; QWidget* topsub = 0; if ( d->lastraised ) { for (QWidget* w = list->first(); w; w = list->next()) { if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { if ( w == d->lastraised ) foundlast = TRUE; if ( foundlast ) { w->raise(); topsub = w; } } } } for (QWidget* w = list->first(); w; w = list->next()) { if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { if ( w == d->lastraised ) break; w->raise(); topsub = w; } } d->lastraised = topsub; delete list; } // 3. Raise the active modal widget. if ( topm ) { topm->show(); topm->raise(); // If we haven't already handled the fastAppShowing message if (!top && d->preloaded) { #ifndef QT_NO_COP QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); e << d->appName; #endif } r = FALSE; } return r; } void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) { #ifdef Q_WS_QWS if ( msg == "quit()" ) { tryQuit(); } else if ( msg == "quitIfInvisible()" ) { if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) quit(); } else if ( msg == "close()" ) { hideOrQuit(); } else if ( msg == "disablePreload()" ) { d->preloaded = FALSE; d->keep_running = TRUE; /* so that quit will quit */ } else if ( msg == "enablePreload()" ) { if (d->qpe_main_widget) d->preloaded = TRUE; d->keep_running = TRUE; /* so next quit won't quit */ } else if ( msg == "raise()" ) { d->keep_running = TRUE; d->notbusysent = FALSE; raiseAppropriateWindow(); // Tell the system we're still chugging along... QCopEnvelope e("QPE/System", "appRaised(QString)"); e << d->appName; } else if ( msg == "flush()" ) { emit flush(); // we need to tell the desktop QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); e << d->appName; } else if ( msg == "reload()" ) { emit reload(); } else if ( msg == "setDocument(QString)" ) { d->keep_running = TRUE; QDataStream stream( data, IO_ReadOnly ); QString doc; stream >> doc; QWidget *mw = mainWidget(); if ( !mw ) mw = d->qpe_main_widget; if ( mw ) Global::setDocument( mw, doc ); } else if ( msg == "QPEProcessQCop()" ) { processQCopFile(); d->sendQCopQ(); }else { bool p = d->keep_running; d->keep_running = FALSE; emit appMessage( msg, data); if ( d->keep_running ) { d->notbusysent = FALSE; raiseAppropriateWindow(); if ( !p ) { // Tell the system we're still chugging along... #ifndef QT_NO_COP QCopEnvelope e("QPE/System", "appRaised(QString)"); e << d->appName; #endif } } if ( p ) d->keep_running = p; } #endif } /*! Sets widget \a mw as the mainWidget() and shows it. For small windows, consider passing TRUE for \a nomaximize rather than the default FALSE. \sa showMainDocumentWidget() */ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) { // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit d->show(mw, nomaximize ); } /*! Sets widget \a mw as the mainWidget() and shows it. For small windows, consider passing TRUE for \a nomaximize rather than the default FALSE. This calls designates the application as a \link docwidget.html document-oriented\endlink application. The \a mw widget \e must have this slot: setDocument(const QString&). \sa showMainWidget() */ void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) { if ( mw && argc() == 2 ) Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); // setMainWidget(mw); see above d->show(mw, nomaximize ); } /*! If an application is started via a \link qcop.html QCop\endlink message, the application will process the \link qcop.html QCop\endlink message and then quit. If the application calls this function while processing a \link qcop.html QCop\endlink message, after processing its outstanding \link qcop.html QCop\endlink messages the application will start 'properly' and show itself. \sa keepRunning() */ void QPEApplication::setKeepRunning() { if ( qApp && qApp->inherits( "QPEApplication" ) ) { QPEApplication * qpeApp = ( QPEApplication* ) qApp; qpeApp->d->keep_running = TRUE; } } /*! Returns TRUE if the application will quit after processing the current list of qcop messages; otherwise returns FALSE. \sa setKeepRunning() */ bool QPEApplication::keepRunning() const { return d->keep_running; } /*! \internal */ void QPEApplication::internalSetStyle( const QString &style ) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if ( style == "QPE" ) { setStyle( new QPEStyle ); } else { QStyle *s = QStyleFactory::create( style ); if ( s ) setStyle( s ); } #else if ( style == "Windows" ) { setStyle( new QWindowsStyle ); } else if ( style == "QPE" ) { setStyle( new QPEStyle ); } else if ( style == "Light" ) { setStyle( new LightStyle ); } #ifndef QT_NO_STYLE_PLATINUM else if ( style == "Platinum" ) { setStyle( new QPlatinumStyle ); } #endif #ifndef QT_NO_STYLE_MOTIF else if ( style == "Motif" ) { setStyle( new QMotifStyle ); } #endif #ifndef QT_NO_STYLE_MOTIFPLUS else if ( style == "MotifPlus" ) { setStyle( new QMotifPlusStyle ); } #endif else { QStyle *sty = 0; QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; #ifdef Q_OS_MACX if ( style. find ( ".dylib" ) > 0 ) path += style; else path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility #else if ( style. find ( ".so" ) > 0 ) path += style; else path = path + "lib" + style. lower ( ) + ".so"; // compatibility #endif static QLibrary *lastlib = 0; static StyleInterface *lastiface = 0; QLibrary *lib = new QLibrary ( path ); StyleInterface *iface = 0; if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) sty = iface-> style ( ); if ( sty ) { setStyle ( sty ); if ( lastiface ) lastiface-> release ( ); lastiface = iface; if ( lastlib ) { lastlib-> unload ( ); delete lastlib; } lastlib = lib; } else { if ( iface ) iface-> release ( ); delete lib; setStyle ( new LightStyle ( )); } } #endif } /*! \internal */ void QPEApplication::prepareForTermination( bool willrestart ) { if ( willrestart ) { QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); lblWait->setAlignment( QWidget::AlignCenter ); lblWait->show(); lblWait->showMaximized(); } { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); } processEvents(); // ensure the message goes out. } /*! \internal */ void QPEApplication::shutdown() { // Implement in server's QPEApplication subclass } /*! \internal */ void QPEApplication::restart() { // Implement in server's QPEApplication subclass } static QPtrDict<void>* stylusDict = 0; static void createDict() { if ( !stylusDict ) stylusDict = new QPtrDict<void>; } /*! Returns the current StylusMode for widget \a w. \sa setStylusOperation() StylusMode */ QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) { if ( stylusDict ) return ( StylusMode ) ( int ) stylusDict->find( w ); return LeftOnly; } /*! \enum QPEApplication::StylusMode \value LeftOnly the stylus only generates LeftButton events (the default). \value RightOnHold the stylus generates RightButton events if the user uses the press-and-hold gesture. \sa setStylusOperation() stylusOperation() */ /*! Causes widget \a w to receive mouse events according to the stylus \a mode. \sa stylusOperation() StylusMode */ void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) { createDict(); if ( mode == LeftOnly ) { stylusDict->remove ( w ); w->removeEventFilter( qApp ); } else { stylusDict->insert( w, ( void* ) mode ); connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); w->installEventFilter( qApp ); } } /*! \reimp */ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) { if ( !o->isWidgetType() ) return FALSE; if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { QMouseEvent * me = ( QMouseEvent* ) e; StylusMode mode = (StylusMode)(int)stylusDict->find(o); switch (mode) { case RightOnHold: switch ( me->type() ) { case QEvent::MouseButtonPress: if ( me->button() == LeftButton ) { static long Pref = 500; // #### pref. d->presswidget = (QWidget*)o; d->presspos = me->pos(); d->rightpressed = FALSE; #ifdef OPIE_WITHROHFEEDBACK if( ! d->RoH ) d->RoH = new Opie::Internal::RoHFeedback; d->RoH->init( me->globalPos(), d->presswidget ); Pref = d->RoH->delay(); #endif if (!d->presstimer ) d->presstimer = startTimer( Pref ); // #### pref. } break; case QEvent::MouseMove: if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { killTimer(d->presstimer); #ifdef OPIE_WITHROHFEEDBACK d->RoH->stop(); #endif d->presstimer = 0; } break; case QEvent::MouseButtonRelease: if ( me->button() == LeftButton ) { if ( d->presstimer ) { killTimer(d->presstimer); #ifdef OPIE_WITHROHFEEDBACK d->RoH->stop( ); #endif d->presstimer = 0; } if ( d->rightpressed && d->presswidget ) { printf( "Send ButtonRelease\n" ); // Right released postEvent( d->presswidget, new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), RightButton, LeftButton + RightButton ) ); // Left released, off-widget postEvent( d->presswidget, new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), LeftButton, LeftButton ) ); postEvent( d->presswidget, new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), LeftButton, LeftButton ) ); d->rightpressed = FALSE; return TRUE; // don't send the real Left release } } break; default: break; } break; default: ; } } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { QKeyEvent *ke = (QKeyEvent *)e; if ( ke->key() == Key_Enter ) { if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); return TRUE; } } } return FALSE; } diff --git a/library/qpestyle.cpp b/library/qpestyle.cpp index b61ada4..0566f6b 100644 --- a/library/qpestyle.cpp +++ b/library/qpestyle.cpp @@ -1,688 +1,688 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "qpestyle.h" #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 #include <qdrawutil.h> #include <qcombobox.h> #include <qtabbar.h> QPEStyle::QPEStyle() { } QPEStyle::~QPEStyle() { } void QPEStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags, const QStyleOption &data) const { switch ( pe ) { case PE_ButtonTool: { QColorGroup mycg = cg; if ( flags & Style_On ) { QBrush fill( cg.mid(), Dense4Pattern ); mycg.setBrush( QColorGroup::Button, fill ); } drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data ); break; } case PE_ButtonCommand: case PE_ButtonDefault: case PE_ButtonBevel: case PE_HeaderSection: { QPen oldPen = p->pen(); p->fillRect( r.x()+1, r.y()+1, r.width()-2, r.height()-2, cg.brush(QColorGroup::Button) ); int x2 = r.right(); int y2 = r.bottom(); if ( flags & (Style_Sunken | Style_Down | Style_On) ) p->setPen( cg.dark() ); else p->setPen( cg.light() ); p->drawLine( r.x(), r.y()+1, r.x(), y2-1 ); p->drawLine( r.x()+1, r.y(), x2-1, r.y() ); if ( flags & (Style_Sunken | Style_Down | Style_On) ) p->setPen( cg.light() ); else p->setPen( cg.dark() ); p->drawLine( x2, r.y()+1, x2, y2-1 ); p->drawLine( r.x()+1, y2, x2-1, y2 ); p->setPen( oldPen ); break; } case PE_FocusRect: break; case PE_Indicator: { QColorGroup mycg( cg ); QBrush fill; if ( flags & Style_Down ) fill = cg.brush( QColorGroup::Button ); else fill = cg.brush( (flags&Style_Enabled) ? QColorGroup::Base : QColorGroup::Background ); mycg.setBrush( QColorGroup::Button, fill ); if ( flags&Style_Enabled ) flags |= Style_Sunken; drawPrimitive( PE_ButtonBevel, p, r, mycg, flags ); if ( flags & Style_On ) { QPointArray a( 7*2 ); int i, xx, yy; xx = r.x()+3; yy = r.y()+5; for ( i=0; i<3; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); xx++; yy++; } yy -= 2; for ( i=3; i<7; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); xx++; yy--; } if ( flags & Style_NoChange ) { p->setPen( mycg.dark() ); } else { p->setPen( mycg.text() ); } p->drawLineSegments( a ); } break; } case PE_ExclusiveIndicator: { static const QCOORD pts1[] = { // dark lines 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; static const QCOORD pts4[] = { // white lines 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, 11,4, 10,3, 10,2 }; static const QCOORD pts5[] = { // inner fill 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; int x, y, w, h; r.rect( &x, &y, &w, &h ); p->eraseRect( x, y, w, h ); QPointArray a( QCOORDARRLEN(pts1), pts1 ); a.translate( x, y ); p->setPen( cg.dark() ); p->drawPolyline( a ); a.setPoints( QCOORDARRLEN(pts4), pts4 ); a.translate( x, y ); p->setPen( cg.light() ); p->drawPolyline( a ); a.setPoints( QCOORDARRLEN(pts5), pts5 ); a.translate( x, y ); QColor fillColor = ( flags&Style_Down || !(flags&Style_Enabled) ) ? cg.button() : cg.base(); p->setPen( fillColor ); p->setBrush( fillColor ) ; p->drawPolygon( a ); if ( flags&Style_On ) { p->setPen( NoPen ); p->setBrush( cg.text() ); p->drawRect( x+5, y+4, 2, 4 ); p->drawRect( x+4, y+5, 4, 2 ); } break; } default: QWindowsStyle::drawPrimitive( pe, p, r, cg, flags, data ); break; } } void QPEStyle::drawControl( ControlElement ce, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how, const QStyleOption &data) const { switch ( ce ) { case CE_PushButton: { const QPushButton *btn = (QPushButton*)widget; SFlags flags; flags = Style_Default; if ( btn->isDown() ) flags |= Style_Down; if ( btn->isOn() ) flags |= Style_On; if ( btn->isEnabled() ) flags |= Style_Enabled; if ( btn->isDefault() ) flags |= Style_Default; if (! btn->isFlat() && !(flags & Style_Down)) flags |= Style_Raised; p->setPen( cg.foreground() ); p->setBrush( QBrush(cg.button(), NoBrush) ); QColorGroup mycg( cg ); if ( flags & Style_On ) { QBrush fill = QBrush( cg.mid(), Dense4Pattern ); mycg.setBrush( QColorGroup::Button, fill ); } drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data ); break; } case CE_TabBarTab: { if ( !widget || !widget->parentWidget() ) break; const QTabBar *tb = (const QTabBar *) widget; bool selected = how & Style_Selected; QRect r2(r); if ( tb->shape() == QTabBar::RoundedAbove ) { p->setPen( cg.light() ); p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() ); if ( r2.left() == 0 ) p->drawPoint( tb->rect().bottomLeft() ); else { p->setPen( cg.light() ); p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() ); } if ( selected ) { p->setPen( cg.background() ); p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 ); p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-2), cg.brush( QColorGroup::Background )); } else { r2.setRect( r2.left() + 2, r2.top() + 2, r2.width() - 4, r2.height() - 2 ); p->setPen( cg.button() ); p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 ); p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-3), cg.brush( QColorGroup::Button )); //do shading; will not work for pixmap brushes QColor bg = cg.button(); // int h,s,v; // bg.hsv( &h, &s, &v ); int n = r2.height()/2; int dark = 100; for ( int i = 1; i < n; i++ ) { dark = (dark * (100+(i*15)/n) )/100; p->setPen( bg.dark( dark ) ); int y = r2.bottom()-n+i; int x1 = r2.left()+1; int x2 = r2.right()-1; p->drawLine( x1, y, x2, y ); } } p->setPen( cg.light() ); p->drawLine( r2.left(), r2.bottom()-1, r2.left(), r2.top() + 2 ); p->drawPoint( r2.left()+1, r2.top() + 1 ); p->drawLine( r2.left()+2, r2.top(), r2.right() - 2, r2.top() ); p->setPen( cg.dark() ); p->drawPoint( r2.right() - 1, r2.top() + 1 ); p->drawLine( r2.right(), r2.top() + 2, r2.right(), r2.bottom() - 1); } else if ( tb->shape() == QTabBar::RoundedBelow ) { if ( selected ) { p->setPen( cg.background() ); p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 ); p->fillRect( QRect( r2.left()+1, r2.top(), r2.width()-2, r2.height()-2), tb->palette().normal().brush( QColorGroup::Background )); } else { p->setPen( cg.dark() ); p->drawLine( r2.left(), r2.top(), r2.right(), r2.top() ); r2.setRect( r2.left() + 2, r2.top(), r2.width() - 4, r2.height() - 2 ); p->setPen( cg.button() ); p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 ); p->fillRect( QRect( r2.left()+1, r2.top()+1, r2.width()-2, r2.height()-3), tb->palette().normal().brush( QColorGroup::Button )); } p->setPen( cg.dark() ); p->drawLine( r2.right(), r2.top(), r2.right(), r2.bottom() - 2 ); p->drawPoint( r2.right() - 1, r2.bottom() - 1 ); p->drawLine( r2.right() - 2, r2.bottom(), r2.left() + 2, r2.bottom() ); p->setPen( cg.light() ); p->drawLine( r2.left(), r2.top()+1, r2.left(), r2.bottom() - 2 ); p->drawPoint( r2.left() + 1, r2.bottom() - 1 ); if ( r2.left() == 0 ) p->drawPoint( tb->rect().topLeft() ); } else { QCommonStyle::drawControl( ce, p, widget, r, cg, how, data ); } break; } default: QWindowsStyle::drawControl( ce, p, widget, r, cg, how, data ); break; } } void QPEStyle::drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how, SCFlags sub, SCFlags subActive, const QStyleOption &data) const { switch ( control ) { case CC_ComboBox: if ( sub & SC_ComboBoxArrow ) { SFlags flags = Style_Default; drawPrimitive( PE_ButtonBevel, p, r, cg, flags, data ); QRect ar = QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget, SC_ComboBoxArrow ), widget ); if ( subActive == SC_ComboBoxArrow ) { p->setPen( cg.dark() ); p->setBrush( cg.brush( QColorGroup::Button ) ); p->drawRect( ar ); } ar.addCoords( 2, 2, -2, -2 ); if ( widget->isEnabled() ) flags |= Style_Enabled; if ( subActive & Style_Sunken ) { flags |= Style_Sunken; } drawPrimitive( PE_ArrowDown, p, ar, cg, flags ); } if ( sub & SC_ComboBoxEditField ) { const QComboBox * cb = (const QComboBox *) widget; QRect re = QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget, SC_ComboBoxEditField ), widget ); if ( cb->hasFocus() && !cb->editable() ) p->fillRect( re.x(), re.y(), re.width(), re.height(), cg.brush( QColorGroup::Highlight ) ); if ( cb->hasFocus() ) { p->setPen( cg.highlightedText() ); p->setBackgroundColor( cg.highlight() ); } else { p->setPen( cg.text() ); p->setBackgroundColor( cg.background() ); } if ( cb->hasFocus() && !cb->editable() ) { QRect re = QStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), widget ); drawPrimitive( PE_FocusRect, p, re, cg, Style_FocusAtBorder, QStyleOption(cg.highlight())); } } break; default: QWindowsStyle::drawComplexControl( control, p, widget, r, cg, how, sub, subActive, data ); break; } } int QPEStyle::pixelMetric( PixelMetric metric, const QWidget *widget ) const { int ret; switch( metric ) { case PM_ButtonMargin: ret = 2; break; case PM_DefaultFrameWidth: ret = 1; break; case PM_ButtonDefaultIndicator: ret = 2; break; case PM_ButtonShiftHorizontal: case PM_ButtonShiftVertical: ret = -1; break; case PM_IndicatorWidth: ret = 15; break; case PM_IndicatorHeight: ret = 13; break; case PM_ExclusiveIndicatorHeight: case PM_ExclusiveIndicatorWidth: ret = 15; break; case PM_ScrollBarExtent: ret = 13; break; case PM_SliderLength: ret = 12; break; default: ret = QWindowsStyle::pixelMetric( metric, widget ); break; } return ret; } QSize QPEStyle::sizeFromContents( ContentsType contents, const QWidget *widget, const QSize &contentsSize, const QStyleOption &data) const { QSize sz(contentsSize); switch ( contents ) { case CT_PopupMenuItem: { if ( !widget || data.isDefault() ) break; sz = QWindowsStyle::sizeFromContents( contents, widget, contentsSize, data ); sz = QSize( sz.width(), sz.height()-2 ); break; } default: sz = QWindowsStyle::sizeFromContents( contents, widget, contentsSize, data ); break; } return sz; } #else #include <qfontmetrics.h> #include <qpalette.h> #include <qdrawutil.h> #include <qscrollbar.h> #include <qbutton.h> #include <qframe.h> #include <qtabbar.h> #define INCLUDE_MENUITEM_DEF #include <qmenudata.h> QPEStyle::QPEStyle() { -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 setButtonMargin(buttonMargin()); setScrollBarExtent(scrollBarExtent().width(),scrollBarExtent().height()); #endif } QPEStyle::~QPEStyle() { } int QPEStyle::buttonMargin() const { return 2; } QSize QPEStyle::scrollBarExtent() const { return QSize(13,13); } void QPEStyle::polish ( QPalette & ) { } void QPEStyle::polish( QWidget *w ) { if ( w->inherits( "QListBox" ) || w->inherits( "QListView" ) || w->inherits( "QPopupMenu" ) || w->inherits( "QSpinBox" ) ) { QFrame *f = (QFrame *)w; f->setFrameShape( QFrame::StyledPanel ); f->setLineWidth( 1 ); } } void QPEStyle::unPolish( QWidget *w ) { if ( w->inherits( "QListBox" ) || w->inherits( "QListView" ) || w->inherits( "QPopupMenu" ) || w->inherits( "QSpinBox" ) ) { QFrame *f = (QFrame *)w; f->setFrameShape( QFrame::StyledPanel ); f->setLineWidth( 2 ); } } int QPEStyle::defaultFrameWidth() const { return 1; } void QPEStyle::drawPanel ( QPainter * p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, int lineWidth, const QBrush * fill ) { qDrawShadePanel( p, QRect(x, y, w, h), g, sunken, lineWidth, fill ); } void QPEStyle::drawButton( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, const QBrush* fill ) { QPen oldPen = p->pen(); if ( sunken ) p->setPen( g.dark() ); else p->setPen( g.light() ); int x2 = x+w-1; int y2 = y+h-1; p->drawLine( x, y, x, y2 ); p->drawLine( x, y, x2, y ); if ( sunken ) p->setPen( g.light() ); else p->setPen( g.dark() ); p->drawLine( x2, y, x2, y2 ); p->drawLine( x, y2, x2, y2 ); p->setPen( oldPen ); p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) ); } void QPEStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h ) { p->fillRect( x, y, w, h, color1 ); } void QPEStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, const QBrush* fill ) { drawButton( p, x, y, w, h, g, sunken, fill ); } QRect QPEStyle::comboButtonRect( int x, int y, int w, int h) { return QRect(x+1, y+1, w-2-14, h-2); } QRect QPEStyle::comboButtonFocusRect( int x, int y, int w, int h) { return QRect(x+2, y+2, w-4-14, h-4); } void QPEStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, bool /*editable*/, bool enabled, const QBrush *fill ) { drawBevelButton( p, x, y, w, h, g, FALSE, fill ); drawBevelButton( p, x+w-14, y, 14, h, g, sunken, fill ); drawArrow( p, QStyle::DownArrow, sunken, x+w-14+ 2, y+ 2, 14- 4, h- 4, g, enabled, &g.brush( QColorGroup::Button ) ); } void QPEStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool on, bool down, bool enabled ) { static const QCOORD pts1[] = { // dark lines 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; static const QCOORD pts4[] = { // white lines 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, 11,4, 10,3, 10,2 }; static const QCOORD pts5[] = { // inner fill 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; p->eraseRect( x, y, w, h ); QPointArray a( QCOORDARRLEN(pts1), pts1 ); a.translate( x, y ); p->setPen( g.dark() ); p->drawPolyline( a ); a.setPoints( QCOORDARRLEN(pts4), pts4 ); a.translate( x, y ); p->setPen( g.light() ); p->drawPolyline( a ); a.setPoints( QCOORDARRLEN(pts5), pts5 ); a.translate( x, y ); QColor fillColor = ( down || !enabled ) ? g.button() : g.base(); p->setPen( fillColor ); p->setBrush( fillColor ) ; p->drawPolygon( a ); if ( on ) { p->setPen( NoPen ); p->setBrush( g.text() ); p->drawRect( x+5, y+4, 2, 4 ); p->drawRect( x+4, y+5, 4, 2 ); } } void QPEStyle::drawIndicator ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, int state, bool down, bool enabled ) { QBrush fill; if ( state == QButton::NoChange ) { QBrush b = p->brush(); QColor c = p->backgroundColor(); p->setBackgroundMode( TransparentMode ); p->setBackgroundColor( green ); fill = QBrush(g.base(), Dense4Pattern); p->setBackgroundColor( c ); p->setBrush( b ); } else if ( down ) fill = g.brush( QColorGroup::Button ); else fill = g.brush( enabled ? QColorGroup::Base : QColorGroup::Background ); drawPanel( p, x, y, w, h, g, TRUE, 1, &fill ); if ( state != QButton::Off ) { QPointArray a( 7*2 ); int i, xx, yy; xx = x+3; yy = y+5; for ( i=0; i<3; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); xx++; yy++; } yy -= 2; for ( i=3; i<7; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); xx++; yy--; } if ( state == QButton::NoChange ) { p->setPen( g.dark() ); } else { p->setPen( g.text() ); } p->drawLineSegments( a ); } } #define HORIZONTAL (sb->orientation() == QScrollBar::Horizontal) #define VERTICAL !HORIZONTAL #define MOTIF_BORDER 2 #define SLIDER_MIN 9 // ### motif says 6 but that's too small /*! \reimp */ void QPEStyle::scrollBarMetrics( const QScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int& buttonDim ) { int maxLength; int length = HORIZONTAL ? sb->width() : sb->height(); int extent = HORIZONTAL ? sb->height() : sb->width(); if ( length > (extent - 1)*2 ) buttonDim = extent; else buttonDim = length/2 - 1; sliderMin = 0; maxLength = length - buttonDim*2; if ( sb->maxValue() == sb->minValue() ) { sliderLength = maxLength; } else { sliderLength = (sb->pageStep()*maxLength)/ (sb->maxValue()-sb->minValue()+sb->pageStep()); uint range = sb->maxValue()-sb->minValue(); if ( sliderLength < SLIDER_MIN || range > INT_MAX/2 ) sliderLength = SLIDER_MIN; if ( sliderLength > maxLength ) sliderLength = maxLength; } sliderMax = sliderMin + maxLength - sliderLength; } /*!\reimp */ QStyle::ScrollControl QPEStyle::scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p ) { if ( !sb->rect().contains( p ) ) return NoScroll; int sliderMin, sliderMax, sliderLength, buttonDim, pos; scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); if (sb->orientation() == QScrollBar::Horizontal) pos = p.x(); else pos = p.y(); if (pos < sliderStart) return SubPage; if (pos < sliderStart + sliderLength) return Slider; if (pos < sliderMax + sliderLength) return AddPage; if (pos < sliderMax + sliderLength + buttonDim) diff --git a/library/qpestyle.h b/library/qpestyle.h index 19ef346..1bde0ff 100644 --- a/library/qpestyle.h +++ b/library/qpestyle.h @@ -1,102 +1,102 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef QPESTYLE_H #define QPESTYLE_H #ifndef QT_H #include "qwindowsstyle.h" #endif // QT_H -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 class Q_EXPORT QPEStyle : public QWindowsStyle { public: QPEStyle(); virtual ~QPEStyle(); virtual void drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags=Style_Default, const QStyleOption & = QStyleOption::Default) const; virtual void drawControl( ControlElement ce, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how=Style_Default, const QStyleOption & = QStyleOption::Default) const; virtual void drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how=Style_Default, SCFlags sub=SC_All, SCFlags subActive=SC_None, const QStyleOption & = QStyleOption::Default) const; virtual int pixelMetric( PixelMetric metric, const QWidget *widget=0 ) const; virtual QSize sizeFromContents( ContentsType contents, const QWidget *widget, const QSize &contentsSize, const QStyleOption & = QStyleOption::Default) const; }; #else class Q_EXPORT QPEStyle : public QWindowsStyle { public: QPEStyle(); virtual ~QPEStyle(); virtual void polish( QPalette &p ); virtual void polish( QWidget *w ); virtual void unPolish( QWidget *w ); int defaultFrameWidth () const; void drawPanel ( QPainter * p, int x, int y, int w, int h, const QColorGroup &, bool sunken=FALSE, int lineWidth = 1, const QBrush * fill = 0 ); void drawButton( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, const QBrush* fill ); void drawButtonMask ( QPainter * p, int x, int y, int w, int h ); void drawBevelButton( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken=FALSE, const QBrush* fill=0 ); QRect comboButtonRect( int x, int y, int w, int h); QRect comboButtonFocusRect( int x, int y, int w, int h); void drawComboButton( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, bool, bool enabled, const QBrush *fill ); void drawExclusiveIndicator ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool on, bool down = FALSE, bool enabled = TRUE ); void drawIndicator ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, int state, bool down = FALSE, bool enabled = TRUE ); void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int&); void drawScrollBarControls( QPainter*, const QScrollBar*, int sliderStart, uint controls, uint activeControl ); ScrollControl scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p ); void drawRiffles( QPainter* p, int x, int y, int w, int h, const QColorGroup &g, bool horizontal ); int sliderLength() const; void drawSlider( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, Orientation, bool tickAbove, bool tickBelow ); void drawSliderMask( QPainter *p, int x, int y, int w, int h, Orientation, bool tickAbove, bool tickBelow ); void drawSliderGrooveMask( QPainter *p, int x, int y, int w, int h, const QColorGroup& , QCOORD c, Orientation orient ); void drawTab( QPainter *, const QTabBar *, QTab *, bool selected ); int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& ); int popupMenuItemHeight( bool checkable, QMenuItem*, const QFontMetrics& ); void drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, const QPalette& pal, bool act, bool enabled, int x, int y, int w, int h); int buttonMargin() const; QSize scrollBarExtent() const; private: // Disabled copy constructor and operator= #if defined(Q_DISABLE_COPY) QPEStyle( const QPEStyle & ); QPEStyle& operator=( const QPEStyle & ); #endif }; #endif #endif // QPESTYLE_H diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp index 98c1793..1199e4f 100644 --- a/noncore/apps/opie-console/TEWidget.cpp +++ b/noncore/apps/opie-console/TEWidget.cpp @@ -11,513 +11,513 @@ /* ------------------------------------------------------------------------ */ /* */ /* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ /*! \class TEWidget \brief Visible screen contents This class is responsible to map the `image' of a terminal emulation to the display. All the dependency of the emulation to a specific GUI or toolkit is localized here. Further, this widget has no knowledge about being part of an emulation, it simply work within the terminal emulation framework by exposing size and key events and by being ordered to show a new image. <ul> <li> The internal image has the size of the widget (evtl. rounded up) <li> The external image used in setImage can have any size. <li> (internally) the external image is simply copied to the internal when a setImage happens. During a resizeEvent no painting is done a paintEvent is expected to follow anyway. </ul> \sa TEScreen \sa Emulation */ /* FIXME: - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent - 'font_a' not used in mouse events - add destructor */ /* TODO - evtl. be sensitive to `paletteChange' while using default colors. - set different 'rounding' styles? I.e. have a mode to show clipped chars? */ // #include "config.h" #include "TEWidget.h" #include <qpe/config.h> #include <qapplication.h> #include <qclipboard.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <sys/stat.h> #include <sys/types.h> #include <signal.h> #include <assert.h> // #include "TEWidget.moc" //#include <kapp.h> //#include <kcursor.h> //#include <kurl.h> //#include <kdebug.h> //#include <klocale.h> #define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) #define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } #define loc(X,Y) ((Y)*columns+(X)) //FIXME: the rim should normally be 1, 0 only when running in full screen mode. #define rimX 0 // left/right rim width #define rimY 0 // top/bottom rim high #define yMouseScroll 1 // scroll increment used when dragging selection at top/bottom of window. /* Button XPM */ namespace { static char * menu_xpm[] = { "12 12 5 1", " c None", ". c #000000", "+ c #FFFDAD", "@ c #FFFF00", "# c #E5E100", " ", " ", " ......... ", " .+++++++. ", " .+@@@@#. ", " .+@@@#. ", " .+@@#. ", " .+@#. ", " .+#. ", " .+. ", " .. ", " "}; } /* ------------------------------------------------------------------------- */ /* */ /* Colors */ /* */ /* ------------------------------------------------------------------------- */ //FIXME: the default color table is in session.C now. // We need a way to get rid of this one, here. static const ColorEntry base_color_table[TABLE_COLORS] = // The following are almost IBM standard color codes, with some slight // gamma correction for the dim colors to compensate for bright X screens. // It contains the 8 ansiterm/xterm colors in 2 intensities. { // Fixme: could add faint colors here, also. // normal ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White // intensiv ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) }; /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) Code 0 1 2 3 4 5 6 7 ----------- ------- ------- ------- ------- ------- ------- ------- ------- ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White */ QColor TEWidget::getDefaultBackColor() { return color_table[DEFAULT_BACK_COLOR].color; } const ColorEntry* TEWidget::getColorTable() const { return color_table; } const ColorEntry* TEWidget::getdefaultColorTable() const { return base_color_table; } const QPixmap *TEWidget::backgroundPixmap() { static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); const QPixmap *pm = bg; return pm; } void TEWidget::setColorTable(const ColorEntry table[]) { for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; const QPixmap* pm = backgroundPixmap(); if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); update(); } //FIXME: add backgroundPixmapChanged. /* ------------------------------------------------------------------------- */ /* */ /* Font */ /* */ /* ------------------------------------------------------------------------- */ /* The VT100 has 32 special graphical characters. The usual vt100 extended xterm fonts have these at 0x00..0x1f. QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals come in here as proper unicode characters. We treat non-iso10646 fonts as VT100 extended and do the requiered mapping from unicode to 0x00..0x1f. The remaining translation is then left to the QCodec. */ // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. unsigned short vt100_graphics[32] = { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 }; static QChar vt100extended(QChar c) { switch (c.unicode()) { case 0x25c6 : return 1; case 0x2592 : return 2; case 0x2409 : return 3; case 0x240c : return 4; case 0x240d : return 5; case 0x240a : return 6; case 0x00b0 : return 7; case 0x00b1 : return 8; case 0x2424 : return 9; case 0x240b : return 10; case 0x2518 : return 11; case 0x2510 : return 12; case 0x250c : return 13; case 0x2514 : return 14; case 0x253c : return 15; case 0xf800 : return 16; case 0xf801 : return 17; case 0x2500 : return 18; case 0xf803 : return 19; case 0xf804 : return 20; case 0x251c : return 21; case 0x2524 : return 22; case 0x2534 : return 23; case 0x252c : return 24; case 0x2502 : return 25; case 0x2264 : return 26; case 0x2265 : return 27; case 0x03c0 : return 28; case 0x2260 : return 29; case 0x00a3 : return 30; case 0x00b7 : return 31; } return c; } static QChar identicalMap(QChar c) { return c; } void TEWidget::fontChange(const QFont &) { QFontMetrics fm(font()); font_h = fm.height(); font_w = fm.maxWidth(); font_a = fm.ascent(); //printf("font_h: %d\n",font_h); //printf("font_w: %d\n",font_w); //printf("font_a: %d\n",font_a); //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); //printf("rawname: %s\n",font().rawName().ascii()); fontMap = -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") ? vt100extended : #endif identicalMap; propagateSize(); update(); } void TEWidget::setVTFont(const QFont& f) { QFrame::setFont(f); } QFont TEWidget::getVTFont() { return font(); } void TEWidget::setFont(const QFont &) { // ignore font change request if not coming from konsole itself } /* ------------------------------------------------------------------------- */ /* */ /* Constructor / Destructor */ /* */ /* ----------------------------------------------------------------------- */ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) { #ifndef QT_NO_CLIPBOARD cb = QApplication::clipboard(); QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), this, SLOT(onClearSelection()) ); #endif scrollbar = new QScrollBar( this ); scrollbar->setCursor( arrowCursor ); connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); hscrollbar = new QScrollBar( Qt::Horizontal, this ); hscrollbar->setCursor( arrowCursor ); connect(hscrollbar, SIGNAL(valueChanged(int)), this, SLOT(hscrollChanged(int))); m_cornerButton = new QPushButton( this ); m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); m_cornerButton->setMaximumSize( 14, 14 ); m_cornerButton->hide(); Config cfg("Konsole"); cfg.setGroup("ScrollBar"); switch( cfg.readNumEntry("Position",2)){ case 0: scrollLoc = SCRNONE; break; case 1: scrollLoc = SCRLEFT; break; case 2: scrollLoc = SCRRIGHT; break; }; blinkT = new QTimer(this); connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); // blinking = FALSE; blinking = TRUE; resizing = FALSE; actSel = 0; image = 0; lines = 1; columns = 1; font_w = 1; font_h = 1; font_a = 1; word_selection_mode = FALSE; vcolumns = 0; hposition = 0; setMouseMarks(TRUE); setVTFont( QFont("fixed") ); setColorTable(base_color_table); // init color table qApp->installEventFilter( this ); //FIXME: see below // KCursor::setAutoHideCursor( this, true ); // Init DnD //////////////////////////////////////////////////////////////// currentSession = NULL; // setAcceptDrops(true); // attempt // m_drop = new QPopupMenu(this); // m_drop->insertItem( QString("Paste"), 0); // m_drop->insertItem( QString("cd"), 1); // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); // we need focus so that the auto-hide cursor feature works setFocus(); setFocusPolicy( WheelFocus ); } //FIXME: make proper destructor // Here's a start (David) TEWidget::~TEWidget() { qApp->removeEventFilter( this ); if (image) free(image); } /* ------------------------------------------------------------------------- */ /* */ /* Display Operations */ /* */ /* ------------------------------------------------------------------------- */ /*! attributed string draw primitive */ void TEWidget::drawAttrStr(QPainter &paint, QRect rect, QString& str, ca attr, BOOL pm, BOOL clear) { if (pm && color_table[attr.b].transparent) { paint.setBackgroundMode( TransparentMode ); if (clear) erase(rect); } else { if (blinking) paint.fillRect(rect, color_table[attr.b].color); else { paint.setBackgroundMode( OpaqueMode ); paint.setBackgroundColor( color_table[attr.b].color ); } } if (color_table[attr.f].bold) paint.setPen(QColor( 0x8F, 0x00, 0x00 )); else paint.setPen(color_table[attr.f].color); paint.drawText(rect.x(),rect.y()+font_a, str); if (attr.r & RE_UNDERLINE) paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); } /*! The image can only be set completely. The size of the new image may or may not match the size of the widget. */ void TEWidget::setImage(const ca* const newimg, int lines, int columns) { int y,x,len; const QPixmap* pm = backgroundPixmap(); QPainter paint; setUpdatesEnabled(FALSE); paint.begin( this ); HCNT("setImage"); QPoint tL = contentsRect().topLeft(); int tLx = tL.x(); int tLy = tL.y(); hasBlinker = FALSE; int cf = -1; // undefined int cb = -1; // undefined int cr = -1; // undefined int lins = QMIN(this->lines, QMAX(0,lines )); int cols = QMIN(this->columns,QMAX(0,columns)); QChar *disstrU = new QChar[cols]; //{ static int cnt = 0; printf("setImage %d\n",cnt++); } for (y = 0; y < lins; y++) { const ca* lcl = &image[y*this->columns]; const ca* const ext = &newimg[y*columns]; if (!resizing) // not while resizing, we're expecting a paintEvent for (x = 0; x < cols; x++) { hasBlinker |= (ext[x].r & RE_BLINK); if (ext[x] != lcl[x]) { cr = ext[x].r; cb = ext[x].b; if (ext[x].f != cf) cf = ext[x].f; int lln = cols - x; disstrU[0] = fontMap(ext[x+0].c); for (len = 1; len < lln; len++) { if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) break; disstrU[len] = fontMap(ext[x+len].c); } QString unistr(disstrU,len); drawAttrStr(paint, QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), unistr, ext[x], pm != NULL, true); x += len - 1; } } // finally, make `image' become `newimg'. memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); } drawFrame( &paint ); paint.end(); setUpdatesEnabled(TRUE); if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } delete [] disstrU; } // paint Event //////////////////////////////////////////////////// /*! The difference of this routine vs. the `setImage' is, that the drawing does not include a difference analysis between the old and the new image. Instead, the internal image is used and the painting bound by the PaintEvent box. */ void TEWidget::paintEvent( QPaintEvent* pe ) { //{ static int cnt = 0; printf("paint %d\n",cnt++); } const QPixmap* pm = backgroundPixmap(); QPainter paint; setUpdatesEnabled(FALSE); paint.begin( this ); paint.setBackgroundMode( TransparentMode ); HCNT("paintEvent"); // Note that the actual widget size can be slightly larger // that the image (the size is truncated towards the smaller // number of characters in `resizeEvent'. The paint rectangle // can thus be larger than the image, but less then the size // of one character. QRect rect = pe->rect().intersect(contentsRect()); QPoint tL = contentsRect().topLeft(); int tLx = tL.x(); int tLy = tL.y(); int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); diff --git a/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp b/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp index 78635b2..7b30b1a 100644 --- a/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp +++ b/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp @@ -1,297 +1,297 @@ /**************************************************************************** ** $Id$ ** ** Implementation of QRegExp class ** ** Created : 950126 ** ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. ** ** This file is part of the tools module of the Qt GUI Toolkit. ** ** This file may be distributed under the terms of the Q Public License ** as defined by Trolltech AS of Norway and appearing in the file ** LICENSE.QPL included in the packaging of this file. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition ** licenses may use this file in accordance with the Qt Commercial License ** Agreement provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for ** information about Qt Commercial License Agreements. ** See http://www.trolltech.com/qpl/ for QPL licensing information. ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ -#if QT_VERSION >=300 +#if QT_VERSION >= 0x030000 #error QRegExp3 is now in QT 3 use QRegExp instead #endif -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 #include "./qregexp3.h" #else #include "qregexp.h" #endif /* OPIE */ #include <opie2/odebug.h> /* QT */ #include <qarray.h> #include <qbitarray.h> #include <qcache.h> #include <qintdict.h> #include <qmap.h> #include <qstring.h> #include <qtl.h> #include <qvector.h> /* STD */ #include <limits.h> /* WARNING! Be sure to read qregexp.tex before modifying this file. */ /*! \class QRegExp3 qregexp.h \brief The QRegExp class provides pattern matching using regular expressions. \ingroup tools \ingroup misc \ingroup shared Regular expressions, "regexps", provide a way to find patterns within text. This is useful in many contexts, for example: <ol> <li>\e Validation. A regexp can be used to check whether a piece of text meets some criteria, e.g. is an integer or contains no whitespace. <li>\e Searching. Regexps provide a much more powerful means of searching text than simple string matching does. For example we can create a regexp which says "find one of the words 'mail', 'letter' or 'correspondence' but not any of the words 'email', 'mailman' 'mailer', 'letterbox' etc." <li><em>Search and Replace.</em> A regexp can be used to replace a pattern with a piece of text, for example replace all occurrences of '&' with '\&' except where the '&' is already followed by 'amp;'. <li><em>String Splitting.</em> A regexp can be used to identify where a string should be split into its component fields, e.g. splitting tab delimited strings. </ol> We present a very brief introduction to regexps, a description of Qt's regexp language, some code examples, and finally the function documentation. QRegExp is modelled on Perl's regexp engine and fully supports Unicode. QRegExp may also be used in the weaker 'wildcard' (globbing) mode which works in a similar way to command shells. A good text on regexps is <i>Mastering Regular Expressions: Powerful Techniques for Perl and Other Tools</i> by Jeffrey E. Friedl, ISBN 1565922573. Experienced regexp users may prefer to skip the introduction and go directly to the relevant information: <ul> <li><a href="#characters-and-abbreviations-for-sets-of-characters"> Characters and Abbreviations for Sets of Characters</a> <li><a href="#sets-of-characters">Sets of Characters</a> <li><a href="#quantifiers">Quantifiers</a> <li><a href="#capturing-text">Capturing Text</a> <li><a href="#assertions">Assertions</a> <li><a href="#wildcard-matching">Wildcard Matching (globbing)</a> <li><a href="#perl-users">Notes for Perl Users</a> <li><a href="#code-examples">Code Examples</a> <li><a href="#member-function-documentation">Member Function Documentation</a> </ul> <b>Introduction</b> Regexps are built up from expressions, quantifiers and assertions. The simplest form of expression is simply a character, e.g. <b>x</b> or <b>5</b>. An expression can also be a set of characters. For example, <b>[ABCD]</b>, will match an <b>A</b> or a <b>B</b> or a <b>C</b> or a <b>D</b>. As a shorthand we could write this as <b>[A-D]</b>. If we want to match any of the captital letters in the English alphabet we can write <b>[A-Z]</b>. A quantifier tells the regexp engine how many occurrences of the expression we want, e.g. <b>x{1,1}</b> means match an <b>x</b> which occurs at least once and at most once. We'll look at assertions and more complex expressions later. Note that regexps cannot be used to check for balanced brackets or tags (unless you know the maximum level of nesting). We'll start by writing a regexp to match integers in the range 0 to 99. We will require at least one digit so we will start with <b>[0-9]{1,1}</b> which means match a digit exactly once. This regexp alone will match integers in the range 0 to 9. To match one or two digits we can increase the maximum number of occurrences so the regexp becomes <b>[0-9]{1,2}</b> meaning match a digit at least once and at most twice. However, this regexp as it stands will not match correctly. This regexp will match one or two digits \e within a string. To ensure that we match against the whole string we must use the anchor assertions. We need <b>^</b> (caret) which when it is the first character in the regexp means that the regexp must match from the beginning of the string. And we also need <b>$</b> (dollar) which when it is the last character in the regexp means that the regexp must match until the end of the string. So now our regexp is <b>^[0-9]{1,2}$</b>. Note that assertions do not match any characters. If you've seen regexps elsewhere they may have looked different from the one above. This is because some sets of characters and some quantifiers are so common that they have special symbols to represent them. <b>[0-9]</b> can be replaced with the symbol <b>\d</b>. The quantifier to match exactly one occurrence, <b>{1,1}</b>, can be replaced with the expression itself. This means that <b>x{1,1}</b> is exactly the same as <b>x</b> alone. So our 0 to 99 matcher could be written: <b>^\d{1,2}$</b>, although most people would write it <b>^\d\d?$</b>. The <b>?</b> is the same as the quantifier <b>{0,1}</b>, i.e. a minimum of no occurrences a maximum of one occurrence. This is used to make an expression optional. The regexp <b>^\d\d?$</b> means "from the beginning of the string match one digit followed by zero or one digits and then the end of the string". Our second example is matching the words 'mail', 'letter' or 'correspondence' but without matching 'email', 'mailman', 'mailer', 'letterbox' etc. We'll start by just matching 'mail'. In full the regexp is, <b>m{1,1}a{1,1}i{1,1}l{1,1}</b>, but since an expression itself is automatically quantified by <b>{1,1}</b> we can simply write this as <b>mail</b>; an 'm' followed by an 'a' followed by an 'i' followed by an 'l'. The symbol '|' (bar) is used for \e alternation, so our regexp now becomes <b>mail|letter|correspondence</b> which means match 'mail' \e or 'letter' \e or 'correspondence'. Whilst this regexp will find the words we want it will also find words we don't want such as 'email'. We will start by putting our regexp in parenthesis <b>(mail|letter|correspondence)</b>. Parenthesis have two effects, firstly they group expressions together and secondly they identify parts of the regexp that we wish to <a href="#capturing-text">capture</a>. Our regexp still matches any of the three words but now they are grouped together as a unit. This is useful for building up more complex regexps. It is also useful because it allows us to examine which of the words actually matched. We need to use another assertion, this time <b>\b</b> "word boundary": <b>\b(mail|letter|correspondence)\b</b>. This regexp means "match a word boundary followed by the expression in parenthesis followed by another word boundary". The <b>\b</b> assertion matches at a \e position in the regexp not a \e character in the regexp. A word boundary is any non-word character such as a space a newline or the beginning or end of the string. For our third example we want to replace ampersands with the HTML entity '\&'. The regexp to match is simple: <b>\&</b>, i.e. match one ampersand. Unfortunately this will mess up our text if some of the ampersands have already been turned into HTML entities. So what we really want to say is replace an ampersand providing it is not followed by 'amp;'. For this we need the negative lookahead assertion and our regexp becomes: <b>\&(?!amp;)</b>. The negative lookahead assertion is introduced with '(?!' and finishes at the ')'. It means that the text it contains, 'amp;' in our example, must \e not follow the expression that preceeds it. Regexps provide a rich language that can be used in a variety of ways. For example suppose we want to count all the occurrences of 'Eric' and 'Eirik' in a string. Two valid regexps to match these are <b>\\</b><b>b(Eric|Eirik)</b><b>\\</b><b>b</b> and <b>\\</b><b>bEi?ri[ck]</b><b>\\</b><b>b</b>. We need the word boundary '\b' so we don't get 'Ericsson' etc. The second regexp actually matches more than we want, 'Eric', 'Erik', 'Eiric' and 'Eirik'. We will implement some the examples above in the <a href="#code-examples">code examples</a> section. <a name="characters-and-abbreviations-for-sets-of-characters"> <b>Characters and Abbreviations for Sets of Characters</b></a> <ul> <li><b>c</b> Any character represents itself unless it has a special regexp meaning. Thus <b>c</b> matches the character \e c. <li><b>\\</b><b>c</b> A character that follows a backslash matches the character itself except where mentioned below. For example if you wished to match a literal caret at the beginning of a string you would write <b>\^</b>. <li><b>\\</b><b>a</b> This matches the ASCII bell character (BEL, 0x07). <li><b>\\</b><b>f</b> This matches the ASCII form feed character (FF, 0x0C). <li><b>\\</b><b>n</b> This matches the ASCII line feed character (LF, 0x0A), (Unix newline). <li><b>\\</b><b>r</b> This matches the ASCII carriage return character (CR, 0x0D). <li><b>\\</b><b>t</b> This matches the ASCII horizontal tab character (HT, 0x09). <li><b>\\</b><b>v</b> This matches the ASCII vertical tab character (VT, 0x0B). <li><b>\\</b><b>xhhhh</b> This matches the Unicode character corresponding to the hexadecimal number hhhh (between 0x0000 and 0xFFFF). \0ooo (i.e., \zero ooo) matches the ASCII/Latin-1 character corresponding to the octal number ooo (between 0 and 0377). <li><b>. (dot)</b> This matches any character (including newline). <li><b>\\</b><b>d</b> This matches a digit (see QChar::isDigit()). <li><b>\\</b><b>D</b> This matches a non-digit. <li><b>\\</b><b>s</b> This matches a whitespace (see QChar::isSpace()). <li><b>\\</b><b>S</b> This matches a non-whitespace. <li><b>\\</b><b>w</b> This matches a word character (see QChar::isLetterOrNumber()). <li><b>\\</b><b>W</b> This matches a non-word character. <li><b>\\</b><b>n</b> The n<sup>th</sup> <a href="#capturing-text">backreference</a>, e.g. \1, \2, etc. </ul> <em>Note that the C++ compiler transforms backslashes in strings so to include a <b>\\</b> in a regexp you will need to enter it twice, i.e. <b>\\</b><b>\\</b>.</em> <a name="sets-of-characters"><b>Sets of Characters</b></a> Square brackets are used to match any character in the set of characters contained within the square brackets. All the character set abbreviations described above can be used within square brackets. Apart from the character set abbreviations and the following two exceptions no characters have special meanings in square brackets. <ul> <li><b>^</b> The caret negates the character set if it occurs as the first character, i.e. immediately after the opening square bracket. For example, <b>[abc]</b> matches 'a' or 'b' or 'c', but <b>[^abc]</b> matches anything \e except 'a' or 'b' or 'c'. <li><b>-</b> The dash is used to indicate a range of characters, for example <b>[W-Z]</b> matches 'W' or 'X' or 'Y' or 'Z'. </ul> Using the predefined character set abbreviations is more portable than using character ranges across platforms and languages. For example, <b>[0-9]</b> matches a digit in Western alphabets but <b>\d</b> matches a digit in \e any alphabet. Note that in most regexp literature sets of characters are called "character classes". <a name="quantifiers"><b>Quantifiers</b></a> By default an expression is automatically quantified by <b>{1,1}</b>, i.e. it should occur exactly once. In the following list <b><i>E</i></b> stands for any expression. An expression is a character or an abbreviation for a set of characters or a set of characters in square brackets or any parenthesised expression. <ul> <li><b><i>E</i>?</b> Matches zero or one occurrence of <i>E</i>. diff --git a/noncore/apps/tinykate/libkate/qt3back/qregexp3.h b/noncore/apps/tinykate/libkate/qt3back/qregexp3.h index 5b75131..fd6bc78 100644 --- a/noncore/apps/tinykate/libkate/qt3back/qregexp3.h +++ b/noncore/apps/tinykate/libkate/qt3back/qregexp3.h @@ -1,111 +1,111 @@ /**************************************************************************** ** $Id$ ** ** Definition of QRegExp class ** ** Created : 950126 ** ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. ** ** This file is part of the tools module of the Qt GUI Toolkit. ** ** This file may be distributed under the terms of the Q Public License ** as defined by Trolltech AS of Norway and appearing in the file ** LICENSE.QPL included in the packaging of this file. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition ** licenses may use this file in accordance with the Qt Commercial License ** Agreement provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for ** information about Qt Commercial License Agreements. ** See http://www.trolltech.com/qpl/ for QPL licensing information. ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef QREGEXP3_H #define QREGEXP3_H #ifndef QT_H #include "qstringlist.h" #endif // QT_H -#if QT_VERSION >=300 +#if QT_VERSION >= 0x030000 #include <qregexp.h> #else class QRegExpEngine; struct QRegExpPrivate; class Q_EXPORT QRegExp3 { public: QRegExp3(); QRegExp3( const QString& pattern, bool caseSensitive = TRUE, bool wildcard = FALSE ); QRegExp3( const QRegExp3& rx ); ~QRegExp3(); QRegExp3& operator=( const QRegExp3& rx ); bool operator==( const QRegExp3& rx ) const; bool operator!=( const QRegExp3& rx ) const { return !operator==( rx ); } bool isEmpty() const; bool isValid() const; QString pattern() const; void setPattern( const QString& pattern ); bool caseSensitive() const; void setCaseSensitive( bool sensitive ); #ifndef QT_NO_REGEXP_WILDCARD bool wildcard() const; void setWildcard( bool wildcard ); #endif bool minimal() const; void setMinimal( bool minimal ); bool exactMatch( const QString& str ); bool exactMatch( const QString& str ) const; #ifndef QT_NO_COMPAT int match( const QString& str, int index, int *len = 0, bool indexIsStart = TRUE ); #endif int search( const QString& str, int start = 0 ); int search( const QString& str, int start = 0 ) const; // QChar versions #ifdef QCHAR_SUPPORT int search(const QChar *str,int start=0); int search(const QChar *str,int start=0) const; int searchRev(const QChar *str,int start=-1); int searchRev(const QChar *str,int start=-1) const ; bool exactMatch(const QChar *str); bool exactMatch(const QChar *str) const; // end QChar versions #endif int searchRev( const QString& str, int start = -1 ); int searchRev( const QString& str, int start = -1 ) const; int matchedLength(); #ifndef QT_NO_REGEXP_CAPTURE QStringList capturedTexts(); QString cap( int nth = 0 ); int pos( int nth = 0 ); #endif private: void compile( bool caseSensitive ); QRegExpEngine *eng; QRegExpPrivate *priv; }; -#endif // QT_VERSION >= 300 +#endif // QT_VERSION >= 0x030000 #endif // QREGEXP_H diff --git a/noncore/apps/zsafe/shadedlistitem.cpp b/noncore/apps/zsafe/shadedlistitem.cpp index 72c6261..7f340f9 100644 --- a/noncore/apps/zsafe/shadedlistitem.cpp +++ b/noncore/apps/zsafe/shadedlistitem.cpp @@ -1,69 +1,69 @@ /* * shadedlistitem.cpp * * (c) 2003 by Jeremy Bowman <jmbowman@alum.mit.edu> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #include "zsafe.h" #include "shadedlistitem.h" ShadedListItem::ShadedListItem(int index, QListViewItem *parent) : QListViewItem(parent) { oddRow = (index % 2 != 0); } ShadedListItem::ShadedListItem(int index, QListView *parent) : QListViewItem(parent), lv(parent) { oddRow = (index % 2 != 0); } ShadedListItem::ShadedListItem(int index, QListView *parent, QListViewItem *after) : QListViewItem(parent, after), lv(parent) { oddRow = (index % 2 != 0); } ShadedListItem::ShadedListItem(int index, QListView *parent, QString label1, QString label2, QString label3) : QListViewItem(parent, label1, label2, label3), lv(parent) { oddRow = (index % 2 != 0); } ShadedListItem::ShadedListItem(int index, QListView *parent, QListViewItem *after, QString label1, QString label2, QString label3) : QListViewItem(parent, after, label1, label2, label3), lv(parent) { oddRow = (index % 2 != 0); } ShadedListItem::~ShadedListItem() { } void ShadedListItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { QColorGroup colors(cg); -#if QT_VERSION >=300 +#if QT_VERSION >= 0x030000 const QColorGroup::ColorRole crole = QColorGroup::Base; // const QWidget::BackgroundMode bgmode = lv->viewport()->backgroundMode(); // const QColorGroup::ColorRole crole = QPalette::backgroundRoleFromMode(bgmode); #else const QColorGroup::ColorRole crole = QColorGroup::Base; #endif if (oddRow) { colors.setColor(crole, *ZSafe::oddRowColor); } else { colors.setColor(crole, *ZSafe::evenRowColor); } QListViewItem::paintCell(p, colors, column, width, alignment); } diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 1670f93..9ec5af9 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp @@ -119,378 +119,378 @@ void WellenreiterConfigWindow::performAutodetection() // try to guess device type QFile m( "/proc/modules" ); if ( m.open( IO_ReadOnly ) ) { int devicetype(0); QString line; QTextStream modules( &m ); while( !modules.atEnd() && !devicetype ) { modules >> line; if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; } if ( devicetype ) { deviceType->setCurrentItem( devicetype ); _guess = devicetype; odebug << "Wellenreiter: guessed device type to be #" << devicetype << "" << oendl; } } } int WellenreiterConfigWindow::driverType() const { QString name = deviceType->currentText(); if ( _devicetype.contains( name ) ) { return _devicetype[name]; } else { return 0; } }; int WellenreiterConfigWindow::hoppingInterval() const { return hopInterval->cleanText().toInt(); } bool WellenreiterConfigWindow::usePrismHeader() const { return prismHeader->isChecked(); } bool WellenreiterConfigWindow::isChannelChecked( int channel ) const { switch ( channel ) { case 1: return channel1->isOn(); case 2: return channel2->isOn(); case 3: return channel3->isOn(); case 4: return channel4->isOn(); case 5: return channel5->isOn(); case 6: return channel6->isOn(); case 7: return channel7->isOn(); case 8: return channel8->isOn(); case 9: return channel9->isOn(); case 10: return channel10->isOn(); case 11: return channel11->isOn(); case 12: return channel12->isOn(); case 13: return channel13->isOn(); case 14: return channel14->isOn(); default: return false; } } void WellenreiterConfigWindow::changedDeviceType(int t) { if ( t != DEVTYPE_FILE ) return; QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); if ( !name.isEmpty() && QFile::exists( name ) ) { interfaceName->insertItem( name ); interfaceName->setCurrentItem( interfaceName->count()-1 ); } else { deviceType->setCurrentItem( _guess ); } } void WellenreiterConfigWindow::synchronizeActionsAndScripts() { if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide(); if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide(); if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide(); //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 ); //newClientScript->setEnabled( newClientAction->currentItem() == 4 ); //newStationScript->setEnabled( newStationAction->currentItem() == 4 ); } void WellenreiterConfigWindow::changedNetworkAction(int ) { synchronizeActionsAndScripts(); } void WellenreiterConfigWindow::changedClientAction(int ) { synchronizeActionsAndScripts(); } void WellenreiterConfigWindow::changedStationAction(int ) { synchronizeActionsAndScripts(); } void WellenreiterConfigWindow::getCaptureFileNameClicked() { QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); odebug << "name = " << name << "" << oendl; if ( !name.isEmpty() ) { captureFileName->setText( name ); } } void WellenreiterConfigWindow::channelAllClicked(int state) { bool b = state; channel1->setChecked( b ); channel2->setChecked( b ); channel3->setChecked( b ); channel4->setChecked( b ); channel5->setChecked( b ); channel6->setChecked( b ); channel7->setChecked( b ); channel8->setChecked( b ); channel9->setChecked( b ); channel10->setChecked( b ); channel11->setChecked( b ); channel12->setChecked( b ); channel13->setChecked( b ); channel14->setChecked( b ); } bool WellenreiterConfigWindow::useGPS() const { return enableGPS->isChecked(); } const QString WellenreiterConfigWindow::gpsHost() const { return useGPS() ? gpsdHost->currentText() : QString::null; } int WellenreiterConfigWindow::gpsPort() const { return useGPS() ? gpsdPort->value() : -1; } void WellenreiterConfigWindow::performAction( const QString& type, const QString& essid, const QString& mac, bool wep, int channel, int /* signal */ /* , const GpsLocation& loc */ ) { int action; QString script; if ( type == "network" ) { action = newNetworkAction->currentItem(); script = newNetworkScript->text(); } else if ( type == "managed" || type == "adhoc" ) { action = newClientAction->currentItem(); script = newClientScript->text(); } else if ( type == "station" ) { action = newStationAction->currentItem(); script = newStationScript->text(); } else { owarn << "WellenreiterConfigWindow::performAction(): unknown type '" << type << "'" << oendl; return; } odebug << "for event '" << type << "' I'm going to perform action " << action << " (script='" << script << "')" << oendl; switch( action ) { case 0: /* Ignore */ return; case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return; case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return; case 3: /* Blink LED */ break; //FIXME: Implement this case 4: /* Run Script */ { /** * * Script Substitution Information: * * $SSID = SSID * $MAC = MAC * $WEP = Wep * $CHAN = Channel * **/ script = script.replace( QRegExp( "$SSID" ), essid ); script = script.replace( QRegExp( "$MAC" ), mac ); script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); odebug << "going to call script '" << script << "'" << oendl; ::system( script ); odebug << "script returned." << oendl; return; } default: assert( false ); } } void WellenreiterConfigWindow::load() { #ifdef Q_WS_X11 #warning Persistent Configuration not yet implemented for standalone X11 build performAutodetection(); #else odebug << "loading configuration settings..." << oendl; /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ OConfig* c = oApp->config(); c->setGroup( "Interface" ); QString interface = c->readEntry( "name", "<none>" ); if ( interface != "<none>" ) { -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 interfaceName->insertItem( interface, 0 ); interfaceName->setCurrentItem( 0 ); #else interfaceName->setCurrentText( interface ); #endif QString device = c->readEntry( "type", "<select>" ); -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 for ( int i = 0; i < deviceType->count(); ++i ) { if ( deviceType->text( i ) == device ) { deviceType->setCurrentItem( i ); break; } } #else deviceType->setCurrentText( device ); #endif } else { performAutodetection(); } prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); c->setGroup( "Capture" ); writeCaptureFile->setChecked( c->readBoolEntry( "writeCaptureFile", true ) ); captureFileName->setEnabled( writeCaptureFile->isChecked() ); getCaptureFileName->setEnabled( writeCaptureFile->isChecked() ); parsePackets->setEnabled( writeCaptureFile->isChecked() ); captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); hexViewBufferUnlimited->setChecked( c->readBoolEntry( "hexViewBufferUnlimited", true ) ); hexViewBufferLimited->setChecked( !c->readBoolEntry( "hexViewBufferUnlimited", true ) ); hexViewBufferSize->setValue( c->readNumEntry( "hexViewBufferSize", 2000 ) ); c->setGroup( "UI" ); lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); openTree->setChecked( c->readBoolEntry( "openTree", true ) ); disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click newClientScript->setText( c->readEntry( "newClientScript", "" ) ); newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click newStationScript->setText( c->readEntry( "newStationScript", "" ) ); synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand c->setGroup( "GPS" ); enableGPS->setChecked( c->readBoolEntry( "use", false ) ); -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); gpsdHost->setCurrentItem( 0 ); #else gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); #endif gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); startGPS->setChecked( c->readBoolEntry( "start", false ) ); commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); #endif } void WellenreiterConfigWindow::save() { #ifdef Q_WS_X11 #warning Persistent Configuration not yet implemented for standalone X11 build #else odebug << "saving configuration settings..." << oendl; /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ OConfig* c = oApp->config(); c->setGroup( "Interface" ); c->writeEntry( "name", interfaceName->currentText() ); c->writeEntry( "type", deviceType->currentText() ); c->writeEntry( "prism", prismHeader->isChecked() ); c->writeEntry( "hop", hopChannels->isChecked() ); c->writeEntry( "interval", hopInterval->value() ); c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); c->setGroup( "Capture" ); c->writeEntry( "writeCaptureFile", writeCaptureFile->isChecked() ); c->writeEntry( "filename", captureFileName->text() ); c->writeEntry( "hexViewBufferUnlimited", hexViewBufferUnlimited->isChecked() ); c->writeEntry( "hexViewBufferSize", hexViewBufferSize->value() ); c->setGroup( "UI" ); c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); c->writeEntry( "openTree", openTree->isChecked() ); c->writeEntry( "disablePM", disablePM->isChecked() ); c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); c->writeEntry( "newNetworkScript", newNetworkScript->text() ); c->writeEntry( "newClientAction", newClientAction->currentItem() ); c->writeEntry( "newClientScript", newClientScript->text() ); c->writeEntry( "newStationAction", newStationAction->currentItem() ); c->writeEntry( "newStationScript", newStationScript->text() ); c->setGroup( "GPS" ); c->writeEntry( "use", enableGPS->isChecked() ); c->writeEntry( "host", gpsdHost->currentText() ); c->writeEntry( "port", gpsdPort->value() ); c->writeEntry( "start", startGPS->isChecked() ); c->writeEntry( "command", commandGPS->text() ); c->write(); #endif } int WellenreiterConfigWindow::hexViewBuffer() const { return hexViewBufferUnlimited->isChecked() ? -1 : hexViewBufferSize->value(); } diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index 9638686..088171c 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp @@ -1,389 +1,389 @@ /* This file is part of the OPIE Project Copyright (c) 2002 Trolltech AS <info@trolltech.com> =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "appearance.h" #include "editScheme.h" #include "stylelistitem.h" #include "decolistitem.h" #include "colorlistitem.h" #include "exceptlistitem.h" #include "sample.h" /* OPIE */ #include <opie2/odevice.h> #include <opie2/ofiledialog.h> #include <opie2/otabwidget.h> #include <opie2/odebug.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qpe/qpemessagebox.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpestyle.h> #include <qpe/lightstyle.h> #include <qpe/styleinterface.h> /* QT */ #include <qbuttongroup.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qdialog.h> #include <qdir.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistbox.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qradiobutton.h> -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 #include <qstylefactory.h> #endif #include <qtoolbutton.h> #include <qwindowsstyle.h> #include <qlistview.h> #include <qheader.h> #include <qvbox.h> #include <qwhatsthis.h> using namespace Opie; using namespace Opie::Ui; using namespace Opie::Core; class DefaultWindowDecoration : public WindowDecorationInterface { public: DefaultWindowDecoration() : ref(0) {} QString name() const { return "Default"; } QPixmap icon() const { return QPixmap(); } QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( uuid == IID_QUnknown ) *iface = this; else if ( uuid == IID_WindowDecoration ) *iface = this; if ( *iface ) (*iface)->addRef(); return QS_OK; } Q_REFCOUNT private: ulong ref; }; QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) { QWidget* tab = new QWidget( parent, "StyleTab" ); QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); m_style_list = new QListBox( tab, "m_style_list" ); vertLayout->addWidget( m_style_list ); QWhatsThis::add( m_style_list, tr( "Styles control the way items such as buttons and scroll bars appear in all applications.\n\nClick here to select an available style." ) ); m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); connect ( m_style_settings, SIGNAL( clicked()), this, SLOT( styleSettingsClicked())); vertLayout-> addWidget ( m_style_settings ); QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) ); QString s = cfg. readEntry ( "Style", "Light" ); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 m_style_list->insertStringList(QStyleFactory::styles()); #else m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); #endif { QString path = QPEApplication::qpeDir ( ); path.append( "/plugins/styles/" ); QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { QString libstr = path; libstr.append( "/" ); libstr.append( *it ); QLibrary *lib = new QLibrary ( libstr ); StyleInterface *iface; if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) { StyleListItem *slit = new StyleListItem ( lib, iface ); m_style_list-> insertItem ( slit ); if ( slit-> key ( ) == s ) m_style_list-> setCurrentItem ( slit ); } else delete lib; } } m_original_style = m_style_list-> currentItem ( ); styleClicked ( m_original_style ); connect( m_style_list, SIGNAL( highlighted(int) ), this, SLOT( styleClicked(int) ) ); return tab; } QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) { QWidget* tab = new QWidget( parent, "DecoTab" ); QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); m_deco_list = new QListBox( tab, "m_deco_list" ); vertLayout->addWidget( m_deco_list ); QWhatsThis::add( m_deco_list, tr( "Window decorations control the way the application title bar and its buttons appear.\n\nClick here to select an available decoration." ) ); QString s = cfg. readEntry ( "Decoration", "libflat.so" ); m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); { QString path = QPEApplication::qpeDir(); path.append( "/plugins/decorations/" ); QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { QString libstr = path; libstr.append( "/" ); libstr.append( *it ); QLibrary *lib = new QLibrary ( libstr ); WindowDecorationInterface *iface; if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) { DecoListItem *dlit = new DecoListItem ( lib, iface ); m_deco_list-> insertItem ( dlit ); if ( dlit-> key ( ) == s ) m_deco_list-> setCurrentItem ( dlit ); } else delete lib; } } m_original_deco = m_deco_list-> currentItem ( ); if ( m_deco_list-> currentItem ( ) < 0 ) m_deco_list-> setCurrentItem ( 0 ); decoClicked ( m_original_deco ); connect( m_deco_list, SIGNAL( highlighted(int) ), this, SLOT( decoClicked(int) ) ); return tab; } QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) { QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); int size = cfg. readNumEntry ( "FontSize", 10 ); m_fontselect = new OFontSelector ( false, parent, "FontTab" ); m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), this, SLOT( fontClicked(const QFont&))); return m_fontselect; } QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) { QWidget *tab = new QWidget( parent, "ColorTab" ); QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); gridLayout->setRowStretch ( 3, 10 ); m_color_list = new QListBox ( tab ); gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); connect( m_color_list, SIGNAL( highlighted(int) ), this, SLOT( colorClicked(int) ) ); QWhatsThis::add( m_color_list, tr( "Color schemes are a collection of colors which are used for various parts of the display.\n\nClick here to select an available scheme." ) ); m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); QString path = QPEApplication::qpeDir ( ); path.append( "/etc/colors/" ); QStringList sl = QDir ( path ). entryList ( "*.scheme" ); for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { QString name = (*it). left ((*it). find ( ".scheme" )); QString pathstr = path; pathstr.append( *it ); Config config ( pathstr, Config::File ); config. setGroup ( "Colors" ); m_color_list-> insertItem ( new ColorListItem ( name, config )); } m_color_list-> setCurrentItem ( 0 ); QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); tempButton->setText( tr( "Edit..." ) ); connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); gridLayout->addWidget( tempButton, 0, 1 ); QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); tempButton = new QPushButton( tab, "deleteSchemeButton" ); tempButton->setText( tr( "Delete" ) ); connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); gridLayout->addWidget( tempButton, 1, 1 ); QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); tempButton = new QPushButton( tab, "saveSchemeButton" ); tempButton->setText( tr( "Save" ) ); connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); gridLayout->addWidget( tempButton, 2, 1 ); QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); return tab; } QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) { QWidget *tab = new QWidget ( parent ); QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) ); QLabel *l = new QLabel ( tab ); l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); QWhatsThis::add( l, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); m_except = new QListView ( tab ); m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 ); m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 ); m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 ); m_except-> addColumn ( tr( "Binary file(s)" )); m_except-> setColumnAlignment ( 0, AlignCenter ); m_except-> setColumnAlignment ( 1, AlignCenter ); m_except-> setColumnAlignment ( 2, AlignCenter ); m_except-> setAllColumnsShowFocus ( true ); m_except-> setMinimumHeight ( 30 ); m_except-> header ( )-> setClickEnabled ( false ); m_except-> header ( )-> setResizeEnabled ( false ); m_except-> header ( )-> setMovingEnabled ( false ); m_except-> setSorting ( -1 ); lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); QWhatsThis::add( m_except, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); connect ( m_except, SIGNAL( clicked(QListViewItem*,const QPoint&,int)), this, SLOT( clickedExcept(QListViewItem*,const QPoint&,int))); QToolButton *tb = new QToolButton ( tab ); tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); tb-> setFocusPolicy ( QWidget::StrongFocus ); lay-> addWidget ( tb, 2, 1 ); connect ( tb, SIGNAL( clicked()), this, SLOT( addExcept())); QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) ); tb = new QToolButton ( tab ); tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); tb-> setFocusPolicy ( QWidget::StrongFocus ); lay-> addWidget ( tb, 3, 1 ); connect ( tb, SIGNAL( clicked()), this, SLOT( delExcept())); QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) ); tb = new QToolButton ( tab ); tb-> setIconSet ( Resource::loadIconSet ( "up" )); tb-> setFocusPolicy ( QWidget::StrongFocus ); lay-> addWidget ( tb, 4, 1 ); connect ( tb, SIGNAL( clicked()), this, SLOT( upExcept())); QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) ); tb = new QToolButton ( tab ); tb-> setIconSet ( Resource::loadIconSet ( "down" )); tb-> setFocusPolicy ( QWidget::StrongFocus ); lay-> addWidget ( tb, 5, 1 ); connect ( tb, SIGNAL( clicked()), this, SLOT( downExcept())); QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); lay-> setRowStretch ( 6, 10 ); lay-> setColStretch ( 0, 10 ); QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); QListViewItem *lvit = 0; for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); } vertLayout-> addSpacing ( 3 ); QFrame *f = new QFrame ( tab ); f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); vertLayout-> addWidget ( f ); vertLayout-> addSpacing ( 3 ); QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); QLabel* label = new QLabel( tr( "Tab style:" ), tab ); gridLayout-> addWidget ( label, 0, 0 ); QWhatsThis::add( label, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); btngrp-> hide ( ); btngrp-> setExclusive ( true ); m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); m_tabstyle_list-> insertItem ( tr( "Tabs" )); diff --git a/noncore/settings/doctab/doctab.cpp b/noncore/settings/doctab/doctab.cpp index feaf538..72eda6b 100644 --- a/noncore/settings/doctab/doctab.cpp +++ b/noncore/settings/doctab/doctab.cpp @@ -1,94 +1,94 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "doctab.h" #include <qpe/global.h> #include <qpe/fontmanager.h> #include <qpe/config.h> #include <qpe/applnk.h> #include <qpe/qpedialog.h> #include <qpe/qpeapplication.h> #if defined(Q_WS_QWS) && !defined(QT_NO_COP) #include <qpe/qcopenvelope_qws.h> #endif #include <qlabel.h> #include <qcheckbox.h> #include <qradiobutton.h> #include <qtabwidget.h> #include <qslider.h> #include <qfile.h> #include <qtextstream.h> #include <qdatastream.h> #include <qmessagebox.h> #include <qcombobox.h> #include <qspinbox.h> #include <qlistbox.h> #include <qdir.h> -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 #include <qstylefactory.h> #endif #include <stdlib.h> DocTabSettings::DocTabSettings( QWidget* parent, const char* name, WFlags fl ) : DocTabSettingsBase( parent, name, TRUE, fl ) { dl = new QPEDialogListener(this); reset(); } DocTabSettings::~DocTabSettings() {} void DocTabSettings::accept() { applyDocTab(); QDialog::accept(); } void DocTabSettings::applyDocTab() { Config cfg( "Launcher" ); cfg.setGroup( "DocTab" ); cfg.writeEntry( "Enable", yes->isChecked() ); cfg.write(); } void DocTabSettings::reject() { reset(); QDialog::reject(); } void DocTabSettings::reset() { } QString DocTabSettings::actualDocTab; void DocTabSettings::done(int r) { QDialog::done(r); close(); } diff --git a/noncore/settings/language/language.cpp b/noncore/settings/language/language.cpp index 14750ac..bf90576 100644 --- a/noncore/settings/language/language.cpp +++ b/noncore/settings/language/language.cpp @@ -1,159 +1,159 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "settings.h" #include <qpe/global.h> #include <qpe/fontmanager.h> #include <qpe/config.h> #include <qpe/applnk.h> #include <qpe/qpedialog.h> #include <qpe/qpeapplication.h> #if defined(Q_WS_QWS) && !defined(QT_NO_COP) #include <qpe/qcopenvelope_qws.h> #endif #include <qlabel.h> #include <qcheckbox.h> #include <qradiobutton.h> #include <qtabwidget.h> #include <qslider.h> #include <qfile.h> #include <qtextstream.h> #include <qdatastream.h> #include <qmessagebox.h> #include <qcombobox.h> #include <qspinbox.h> #include <qlistbox.h> #include <qdir.h> -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 #include <qstylefactory.h> #endif #include <stdlib.h> LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) : LanguageSettingsBase( parent, name, TRUE, fl ) { if ( FontManager::hasUnicodeFont() ) languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); QString tfn = QPEApplication::qpeDir() + "i18n/"; QDir langDir = tfn; QStringList list = langDir.entryList("*", QDir::Dirs ); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { QString name = (*it); QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); if ( desktopFile.exists() ) { langAvail.append(name); Config conf( desktopFile.filePath(), Config::File ); QString langName = conf.readEntry( "Name" ); QString ownName = conf.readEntryDirect( "Name[" + name + "]" ); if ( ownName.isEmpty() ) ownName = conf.readEntryDirect( "Name" ); if ( !ownName.isEmpty() && ownName != langName ) langName = langName + " [" + ownName + "]"; languages->insertItem( langName ); } } if ( langAvail. find ( "en" ) == -1 ) { langAvail. prepend ( "" ); // no tr languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 ); } dl = new QPEDialogListener(this); reset(); } LanguageSettings::~LanguageSettings() {} void LanguageSettings::accept() { Config c( "qpe" ); c.setGroup( "Startup" ); if ( ( c.readNumEntry( "FirstUse", 42 ) == 0 ) && ( QMessageBox::warning( this, tr("Language"), tr("<qt>Attention, all windows will be closed by changing the language\n" "without saving the Data.<br><br>Go on?</qt>"), 1, 2) ) == QMessageBox::Cancel ) return; applyLanguage(); QDialog::accept(); } void LanguageSettings::applyLanguage() { setLanguage ( langAvail. at ( languages-> currentItem ( ))); } void LanguageSettings::reject() { reset(); QDialog::reject(); } void LanguageSettings::reset() { QString l = getenv("LANG"); Config config("locale"); config.setGroup("Language"); l = config.readEntry( "Language", l ); actualLanguage = l; if (l.isEmpty()) l = "en"; int n = langAvail.find( l ); languages->setCurrentItem( n ); } QString LanguageSettings::actualLanguage; void LanguageSettings::setLanguage(const QString& lang) { if ( lang != actualLanguage ) { Config config("locale"); config.setGroup( "Language" ); if ( lang. isEmpty ( )) config. removeEntry ( "Language" ); else config.writeEntry( "Language", lang ); config.write(); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) QCopEnvelope e("QPE/System", "language(QString)"); e << lang; #endif } } void LanguageSettings::done(int r) { QDialog::done(r); close(); } diff --git a/noncore/settings/networksettings/interfaces/module.h b/noncore/settings/networksettings/interfaces/module.h index 9dc913e..13189c3 100644 --- a/noncore/settings/networksettings/interfaces/module.h +++ b/noncore/settings/networksettings/interfaces/module.h @@ -1,188 +1,188 @@ #ifndef NETCONF_MODULE_H #define NETCONF_MODULE_H #include <qobject.h> -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 #include <qlist.h> #else #include <qptrlist.h> #endif #include <qmap.h> #include "interface.h" class QWidget; class QTabWidget; /** * \brief The basis of all plugins * * This is the way to extend networksettings with * extra functionality. * * * Networksettings in the 1.0 release does not use QCOM * for activation. You need to provide the following function yourself. * * A module needs to provide Name, Images, and methods for * claiming interfaces. For example you can claim physicla * interfaces like wlan0, ppp0 or virtual like a VPN * connection and hide the real ppp device or ethernet device * behind your VPN plugin. * * During start up. The main application searches for network devices * and then looks for an owner under the plugins for them. * For example the WLAN Plugin looks if there is a WLAN Extension * on that interface and then claims it by returning true from isOwner() * * \code * extern "C" * { * void* create_plugin() { * return new WLANModule(); * } * }; * \endcode * @see isOwner(Interface*) */ class Module : private QObject{ signals: /** * Emit this Signal once you change the Interface * you're operating on * * @param i The Interface */ void updateInterface(Interface *i); public: Module(){}; /** * The type of the plugin * and the name of the qcop call */ virtual const QString type() = 0; /** * The current profile has been changed and the module should do any * neccesary changes also. * As of Opie1.0 profiles are disabled. * * @param newProfile what the profile should be changed to. */ virtual void setProfile(const QString &newProfile) = 0; /** * get the icon name for this device. * @param Interface* can be used in determining the icon. * @return QString the icon name (minus .png, .gif etc) */ virtual QString getPixmapName(Interface *) = 0; /** * Check to see if the interface i is owned by this module. * See if you can handle it. And if you can claim ownership * by returning true. * For physical devices you will be asked if you want to own the * device. But you can also create new \sa Interface Implementations. * * If you want to own the Interface add it to your internal interface * list * * @param Interface* interface to check against * @return bool true if i is owned by this module, false otherwise. * * @see getInterfaces */ virtual bool isOwner(Interface *){ return false; }; /** * Create and return the Configure Module * @param Interface *i the interface to configure. * @return QWidget* pointer to this modules configure. * * @see InterfaceSetupImp */ virtual QWidget *configure(Interface *){ return NULL; } ; /** * Create, and return the Information Module. * * An default Implementation is InterfaceInformationImp * * @param Interface *i the interface to get info on. * @return QWidget* pointer to this modules info. * * @see InterfaceInformationImp * */ virtual QWidget *information(Interface *){ return NULL; }; /** * Get all active (up or down) interfaces managed by this * module. * At the end of initialisation you will be asked to return your interfaces * Return all of your interfaces even the ones you claimed by isOnwer. * Here you can also return your 'virtual' Interface Objects * * @return QList<Interface> A list of interfaces that exsist that havn't * been called by isOwner() */ virtual QList<Interface> getInterfaces() = 0; /** * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), * modem ppp) * Both strings need to be translated. The first string is a Shortcut * like PPP and the second argument is a description. * * <code> * list.insert( * * </code> * * @param list A reference to the list of supported additionns. */ virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; /** * Attempts to create a new interface from name you gave * possibleNewInterfaces() * @return Interface* NULL if it was unable to be created. * @param name the type of interface to create * * @see possibleNewInterfaces */ virtual Interface *addNewInterface(const QString &name) = 0; /** * Attempts to remove the interface, doesn't delete i * @return bool true if successful, false otherwise. */ virtual bool remove(Interface* i) = 0; /** * get dcop calls */ virtual void receive(const QCString &msg, const QByteArray &arg) = 0; QStringList handledInterfaceNames()const { return m_inter; } protected: /** * set which interfaceNames should not be shown cause they're handled * internally of this module.. An already running ppp link or * a tunnel... VPN an such */ void setHandledInterfaceNames( const QStringList& in) { m_inter = in; } private: QStringList m_inter; }; #endif // module.h diff --git a/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp b/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp index 84f1cf6..9049af4 100644 --- a/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp +++ b/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp @@ -1,41 +1,41 @@ #include "addconnectionimp.h" #include <qlistview.h> -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 #include <qlist.h> #else #include <qptrlist.h> #endif #include <qlabel.h> #include <qheader.h> /** * Constructor */ AddConnectionImp::AddConnectionImp(QWidget *parent, const char *name, WFlags f):AddConnection(parent, name, f){ connect(registeredServicesList, SIGNAL(selectionChanged()), this, SLOT(changed())); registeredServicesList->header()->hide(); }; /** * The current item changed, update the discription. */ void AddConnectionImp::changed(){ QListViewItem *item = registeredServicesList->currentItem(); if(item) help->setText(list[item->text(0)]); } /** * Save a copy of newList for the discriptions and append them all to the view * @param newList the new list of possible interfaces */ void AddConnectionImp::addConnections(const QMap<QString, QString> &newList){ list = newList; QMap<QString, QString>::Iterator it; for( it = list.begin(); it != list.end(); ++it ) (void)new QListViewItem(registeredServicesList, it.key()); registeredServicesList->setCurrentItem(registeredServicesList->firstChild()); } // addserviceimp.cpp diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp index 5f23aea..8feb7a5 100644 --- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp @@ -1,284 +1,284 @@ #include "mainwindowimp.h" #include "addconnectionimp.h" #include "interfaceinformationimp.h" #include "interfacesetupimp.h" #include "interfaces.h" #include "module.h" /* OPIE */ #include <opie2/odebug.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/qlibrary.h> #include <qpe/resource.h> /* QT */ #include <qpushbutton.h> #include <qlistbox.h> #include <qlineedit.h> #include <qlistview.h> #include <qheader.h> #include <qlabel.h> #include <qtabwidget.h> // in order to disable the profiles tab #include <qmessagebox.h> -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 #include <qlist.h> #else #include <qptrlist.h> #endif #include <qdir.h> #include <qfile.h> #include <qtextstream.h> #include <qregexp.h> /* STD */ #include <net/if.h> #include <sys/ioctl.h> #include <sys/socket.h> #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" #define _PROCNETDEV "/proc/net/dev" MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) { connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); //remove tab with no function tabWidget->removePage( tab ); // Load connections. // /usr/local/kde/lib/libinterfaces.la loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); getAllInterfaces(); Interfaces i; QStringList list = i.getInterfaceList(); QMap<QString, Interface*>::Iterator it; for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { /* * we skipped it in getAllInterfaces now * we need to ignore it as well */ if (m_handledIfaces.contains( *ni) ) { odebug << "Not up iface handled by module" << oendl; continue; } bool found = false; for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ) { if(it.key() == (*ni)) found = true; } if(!found) { if(!(*ni).contains("_")) { Interface *i = new Interface(this, *ni, false); i->setAttached(false); i->setHardwareName(tr("Disconnected")); interfaceNames.insert(i->getInterfaceName(), i); updateInterface(i); connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*))); } } } //getInterfaceList(); connectionList->header()->hide(); Config cfg("NetworkSetup"); profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) profilesList->insertItem((*it)); currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); QFile file(scheme); if ( file.open(IO_ReadOnly) ) { // file opened successfully QTextStream stream( &file ); // use a text stream while ( !stream.eof() ) { // until end of file... QString line = stream.readLine(); // line of text excluding '\n' if(line.contains("SCHEME")) { line = line.mid(7, line.length()); currentProfileLabel->setText(line); break; } } file.close(); } makeChannel(); } /** * Deconstructor. Save profiles. Delete loaded libraries. */ MainWindowImp::~MainWindowImp() { // Save profiles. Config cfg("NetworkSetup"); cfg.setGroup("General"); cfg.writeEntry("Profiles", profiles.join(" ")); // Delete all interfaces that don't have owners. QMap<Interface*, QListViewItem*>::Iterator iIt; for( iIt = items.begin(); iIt != items.end(); ++iIt ) { if(iIt.key()->getModuleOwner() == NULL) delete iIt.key(); } // Delete Modules and Libraries QMap<Module*, QLibrary*>::Iterator it; for( it = libraries.begin(); it != libraries.end(); ++it ) { delete it.key(); // I wonder why I can't delete the libraries // What fucking shit this is. //delete it.data(); } } /** * Query the kernel for all of the interfaces. */ void MainWindowImp::getAllInterfaces() { int sockfd = socket(PF_INET, SOCK_DGRAM, 0); if(sockfd == -1) return; struct ifreq ifr; QStringList ifaces; QFile procFile(QString(_PROCNETDEV)); int result; Interface *i; if (! procFile.exists()) { struct ifreq ifrs[100]; struct ifconf ifc; ifc.ifc_len = sizeof(ifrs); ifc.ifc_req = ifrs; result = ioctl(sockfd, SIOCGIFCONF, &ifc); for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { struct ifreq *pifr = &ifrs[i]; ifaces += pifr->ifr_name; } } else { procFile.open(IO_ReadOnly); QString line; QTextStream procTs(&procFile); int loc = -1; procTs.readLine(); // eat a line procTs.readLine(); // eat a line while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { if((loc = line.find(":")) != -1) { ifaces += line.left(loc); } } } for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { int flags = 0; if ( m_handledIfaces.contains( (*it) ) ) { odebug << " " << (*it).latin1() << " is handled by a module" << oendl; continue; } // int family; i = NULL; strcpy(ifr.ifr_name, (*it).latin1()); struct ifreq ifcopy; ifcopy = ifr; result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); flags = ifcopy.ifr_flags; i = new Interface(this, ifr.ifr_name, false); i->setAttached(true); if ((flags & IFF_UP) == IFF_UP) i->setStatus(true); else i->setStatus(false); if ((flags & IFF_BROADCAST) == IFF_BROADCAST) i->setHardwareName("Ethernet"); else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) i->setHardwareName("Point to Point"); else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) i->setHardwareName("Multicast"); else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) i->setHardwareName("Loopback"); else i->setHardwareName("Unknown"); owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl; interfaceNames.insert(i->getInterfaceName(), i); updateInterface(i); connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*))); } // now lets ask the plugins too ;) QMap<Module*, QLibrary*>::Iterator it; QList<Interface> ilist; for( it = libraries.begin(); it != libraries.end(); ++it ) { if(it.key()) { ilist = it.key()->getInterfaces(); for( i = ilist.first(); i != 0; i = ilist.next() ) { owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl; interfaceNames.insert(i->getInterfaceName(), i); updateInterface(i); connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*))); } } } } /** * Load all modules that are found in the path * @param path a directory that is scaned for any plugins that can be loaded * and attempts to load them */ void MainWindowImp::loadModules(const QString &path) { #ifdef DEBUG odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl; #endif QDir d(path); if(!d.exists()) return; QString lang = ::getenv("LANG"); // Don't want sym links d.setFilter( QDir::Files | QDir::NoSymLinks ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; while ( (fi=it.current()) ) diff --git a/noncore/unsupported/qpdf/QOutputDev.cpp b/noncore/unsupported/qpdf/QOutputDev.cpp index 022d938..487177c 100644 --- a/noncore/unsupported/qpdf/QOutputDev.cpp +++ b/noncore/unsupported/qpdf/QOutputDev.cpp @@ -341,513 +341,513 @@ void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash ) } switch (state->getLineJoin()) { case 0: join = MiterJoin; break; case 1: join = RoundJoin; break; case 2: join = BevelJoin; break; default: qWarning ( "Bad line join style (%d)\n", state->getLineJoin ( )); join = MiterJoin; break; } state-> getLineDash ( &dashPattern, &dashLength, &dashStart ); QColor oldcol = m_painter-> pen ( ). color ( ); GfxRGB rgb; state-> getStrokeRGB ( &rgb ); oldcol = q_col ( rgb ); m_painter-> setPen ( QPen ( oldcol, width, dashLength > 0 ? DashLine : SolidLine, cap, join )); if ( updateDash && ( dashLength > 0 )) { // Not supported by QT /* char dashList[20]; if (dashLength > 20) dashLength = 20; for ( int i = 0; i < dashLength; ++i ) { dashList[i] = xoutRound(state->transformWidth(dashPattern[i])); if (dashList[i] == 0) dashList[i] = 1; } XSetDashes(display, strokeGC, xoutRound(dashStart), dashList, dashLength); */ } } void QOutputDev::updateFillColor ( GfxState *state ) { GfxRGB rgb; state-> getFillRGB ( &rgb ); m_painter-> setBrush ( q_col ( rgb )); } void QOutputDev::updateStrokeColor ( GfxState *state ) { GfxRGB rgb; state-> getStrokeRGB ( &rgb ); QPen pen = m_painter-> pen ( ); pen. setColor ( q_col ( rgb )); m_painter-> setPen ( pen ); } void QOutputDev::updateFont ( GfxState *state ) { fp_t m11, m12, m21, m22; GfxFont *gfxFont = state-> getFont ( ); if ( !gfxFont ) return; state-> getFontTransMat ( &m11, &m12, &m21, &m22 ); m11 *= state-> getHorizScaling ( ); m12 *= state-> getHorizScaling ( ); QFont font = matchFont ( gfxFont, m11, m12, m21, m22 ); m_painter-> setFont ( font ); m_text-> updateFont ( state ); } void QOutputDev::stroke ( GfxState *state ) { QPointArray points; QArray<int> lengths; // transform points int n = convertPath ( state, points, lengths ); QPDFDBG( printf ( "DRAWING: %d POLYS\n", n )); // draw each subpath int j = 0; for ( int i = 0; i < n; i++ ) { int len = lengths [i]; if ( len >= 2 ) { QPDFDBG( printf ( " - POLY %d: ", i )); QPDFDBG( for ( int ii = 0; ii < len; ii++ )) QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( ))); QPDFDBG( printf ( "\n" )); m_painter-> drawPolyline ( points, j, len ); } j += len; } qApp-> processEvents ( ); } void QOutputDev::fill ( GfxState *state ) { doFill ( state, true ); } void QOutputDev::eoFill ( GfxState *state ) { doFill ( state, false ); } // // X doesn't color the pixels on the right-most and bottom-most // borders of a polygon. This means that one-pixel-thick polygons // are not colored at all. I think this is supposed to be a // feature, but I can't figure out why. So after it fills a // polygon, it also draws lines around the border. This is done // only for single-component polygons, since it's not very // compatible with the compound polygon kludge (see convertPath()). // void QOutputDev::doFill ( GfxState *state, bool winding ) { QPointArray points; QArray<int> lengths; // transform points int n = convertPath ( state, points, lengths ); QPDFDBG( printf ( "FILLING: %d POLYS\n", n )); QPen oldpen = m_painter-> pen ( ); m_painter-> setPen ( QPen ( NoPen )); // draw each subpath int j = 0; for ( int i = 0; i < n; i++ ) { int len = lengths [i]; if ( len >= 3 ) { QPDFDBG( printf ( " - POLY %d: ", i )); QPDFDBG( for ( int ii = 0; ii < len; ii++ )) QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( ))); QPDFDBG( printf ( "\n" )); m_painter-> drawPolygon ( points, winding, j, len ); } j += len; } m_painter-> setPen ( oldpen ); qApp-> processEvents ( ); } void QOutputDev::clip ( GfxState *state ) { doClip ( state, true ); } void QOutputDev::eoClip ( GfxState *state ) { doClip ( state, false ); } void QOutputDev::doClip ( GfxState *state, bool winding ) { QPointArray points; QArray<int> lengths; // transform points int n = convertPath ( state, points, lengths ); QRegion region; QPDFDBG( printf ( "CLIPPING: %d POLYS\n", n )); // draw each subpath int j = 0; for ( int i = 0; i < n; i++ ) { int len = lengths [i]; if ( len >= 3 ) { QPointArray dummy; dummy. setRawData ( points. data ( ) + j, len ); QPDFDBG( printf ( " - POLY %d: ", i )); QPDFDBG( for ( int ii = 0; ii < len; ii++ ) printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( ))); QPDFDBG( printf ( "\n" )); region |= QRegion ( dummy, winding ); dummy. resetRawData ( points. data ( ) + j, len ); } j += len; } if ( m_painter && m_painter-> hasClipping ( )) region &= m_painter-> clipRegion ( ); // m_painter-> setClipRegion ( region ); // m_painter-> setClipping ( true ); // m_painter-> fillRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( ), red ); // m_painter-> drawText ( points [0]. x ( ) + 10, points [0]. y ( ) + 10, "Bla bla" ); qApp-> processEvents ( ); } // // Transform points in the path and convert curves to line segments. // Builds a set of subpaths and returns the number of subpaths. // If <fillHack> is set, close any unclosed subpaths and activate a // kludge for polygon fills: First, it divides up the subpaths into // non-overlapping polygons by simply comparing bounding rectangles. // Then it connects subaths within a single compound polygon to a single // point so that X can fill the polygon (sort of). // int QOutputDev::convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths ) { GfxPath *path = state-> getPath ( ); int n = path-> getNumSubpaths ( ); lengths. resize ( n ); // do each subpath for ( int i = 0; i < n; i++ ) { // transform the points lengths [i] = convertSubpath ( state, path-> getSubpath ( i ), points ); } return n; } // // Transform points in a single subpath and convert curves to line // segments. // int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points ) { int oldcnt = points. count ( ); fp_t x0, y0, x1, y1, x2, y2, x3, y3; int m = subpath-> getNumPoints ( ); int i = 0; while ( i < m ) { if ( i >= 1 && subpath-> getCurve ( i )) { state-> transform ( subpath-> getX ( i - 1 ), subpath-> getY ( i - 1 ), &x0, &y0 ); state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 ); state-> transform ( subpath-> getX ( i + 1 ), subpath-> getY ( i + 1 ), &x2, &y2 ); state-> transform ( subpath-> getX ( i + 2 ), subpath-> getY ( i + 2 ), &x3, &y3 ); QPointArray tmp; tmp. setPoints ( 4, lrint ( x0 ), lrint ( y0 ), lrint ( x1 ), lrint ( y1 ), lrint ( x2 ), lrint ( y2 ), lrint ( x3 ), lrint ( y3 )); -#if QT_VERSION < 300 +#if QT_VERSION < 0x030000 tmp = tmp. quadBezier ( ); for ( uint loop = 0; loop < tmp. count ( ); loop++ ) { QPoint p = tmp. point ( loop ); points. putPoints ( points. count ( ), 1, p. x ( ), p. y ( )); } #else tmp = tmp. cubicBezier ( ); points. putPoints ( points. count ( ), tmp. count ( ), tmp ); #endif i += 3; } else { state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 ); points. putPoints ( points. count ( ), 1, lrint ( x1 ), lrint ( y1 )); ++i; } } return points. count ( ) - oldcnt; } void QOutputDev::beginString ( GfxState *state, GString */*s*/ ) { m_text-> beginString ( state ); } void QOutputDev::endString ( GfxState */*state*/ ) { m_text-> endString ( ); } void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y, fp_t dx, fp_t dy, fp_t originX, fp_t originY, CharCode code, Unicode *u, int uLen ) { fp_t x1, y1, dx1, dy1; if ( uLen > 0 ) m_text-> addChar ( state, x, y, dx, dy, u, uLen ); // check for invisible text -- this is used by Acrobat Capture if (( state-> getRender ( ) & 3 ) == 3 ) { return; } x -= originX; y -= originY; state-> transform ( x, y, &x1, &y1 ); state-> transformDelta ( dx, dy, &dx1, &dy1 ); if ( uLen > 0 ) { QString str; QFontMetrics fm = m_painter-> fontMetrics ( ); for ( int i = 0; i < uLen; i++ ) { QChar c = QChar ( u [i] ); if ( fm. inFont ( c )) { str [i] = QChar ( u [i] ); } else { str [i] = ' '; QPDFDBG( printf ( "CHARACTER NOT IN FONT: %hx\n", c. unicode ( ))); } } if (( uLen == 1 ) && ( str [0] == ' ' )) return; fp_t m11, m12, m21, m22; state-> getFontTransMat ( &m11, &m12, &m21, &m22 ); m11 *= state-> getHorizScaling ( ); m12 *= state-> getHorizScaling ( ); fp_t fsize = m_painter-> font ( ). pixelSize ( ); #ifndef QT_NO_TRANSFORMATIONS QWMatrix oldmat; bool dorot = (( m12 < -0.1 ) || ( m12 > 0.1 )) && (( m21 < -0.1 ) || ( m21 > 0.1 )); if ( dorot ) { oldmat = m_painter-> worldMatrix ( ); std::cerr << std::endl << "ROTATED: " << m11 << ", " << m12 << ", " << m21 << ", " << m22 << " / SIZE: " << fsize << " / TEXT: " << str. local8Bit ( ) << endl << endl; QWMatrix mat ( lrint ( m11 / fsize ), lrint ( m12 / fsize ), -lrint ( m21 / fsize ), -lrint ( m22 / fsize ), lrint ( x1 ), lrint ( y1 )); m_painter-> setWorldMatrix ( mat ); x1 = 0; y1 = 0; } #endif QPen oldpen = m_painter-> pen ( ); if (!( state-> getRender ( ) & 1 )) { QPen fillpen = oldpen; fillpen. setColor ( m_painter-> brush ( ). color ( )); m_painter-> setPen ( fillpen ); } if ( fsize > 5 ) m_painter-> drawText ( lrint ( x1 ), lrint ( y1 ), str ); else m_painter-> fillRect ( lrint ( x1 ), lrint ( y1 ), lrint ( QMAX( fp_t(1), dx1 )), lrint ( QMAX( fsize, dy1 )), m_painter-> pen ( ). color ( )); m_painter-> setPen ( oldpen ); #ifndef QT_NO_TRANSFORMATIONS if ( dorot ) m_painter-> setWorldMatrix ( oldmat ); #endif QPDFDBG( printf ( "DRAW TEXT: \"%s\" at (%ld/%ld)\n", str. local8Bit ( ). data ( ), lrint ( x1 ), lrint ( y1 ))); } else if ( code != 0 ) { // some PDF files use CID 0, which is .notdef, so just ignore it qWarning ( "Unknown character (CID=%d Unicode=%hx)\n", code, (unsigned short) ( uLen > 0 ? u [0] : (Unicode) 0 )); } qApp-> processEvents ( ); } void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str, int width, int height, GBool invert, GBool inlineImg ) { // get CTM, check for singular matrix fp_t *ctm = state-> getCTM ( ); if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) { qWarning ( "Singular CTM in drawImage\n" ); if ( inlineImg ) { str-> reset ( ); int j = height * (( width + 7 ) / 8 ); for ( int i = 0; i < j; i++ ) str->getChar(); str->close(); } return; } GfxRGB rgb; state-> getFillRGB ( &rgb ); uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff ); QImage img ( width, height, 32 ); img. setAlphaBuffer ( true ); QPDFDBG( printf ( "IMAGE MASK (%dx%d)\n", width, height )); // initialize the image stream ImageStream *imgStr = new ImageStream ( str, width, 1, 1 ); imgStr-> reset ( ); uchar **scanlines = img. jumpTable ( ); if ( ctm [3] > 0 ) scanlines += ( height - 1 ); for ( int y = 0; y < height; y++ ) { QRgb *scanline = (QRgb *) *scanlines; if ( ctm [0] < 0 ) scanline += ( width - 1 ); for ( int x = 0; x < width; x++ ) { Guchar alpha; imgStr-> getPixel ( &alpha ); if ( invert ) alpha ^= 1; *scanline = ( alpha == 0 ) ? 0xff000000 | val : val; ctm [0] < 0 ? scanline-- : scanline++; } ctm [3] > 0 ? scanlines-- : scanlines++; qApp-> processEvents ( ); } #ifndef QT_NO_TRANSFORMATIONS QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] ); std::cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << std::endl << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << std::endl; QWMatrix oldmat = m_painter-> worldMatrix ( ); m_painter-> setWorldMatrix ( mat, true ); #ifdef QWS QPixmap pm; pm. convertFromImage ( img ); m_painter-> drawPixmap ( 0, 0, pm ); #else m_painter-> drawImage ( QPoint ( 0, 0 ), img ); #endif m_painter-> setWorldMatrix ( oldmat ); #else if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" )); } else { int x = lrint ( ctm [4] ); int y = lrint ( ctm [5] ); int w = lrint ( ctm [0] ); int h = lrint ( ctm [3] ); if ( w < 0 ) { x += w; w = -w; } if ( h < 0 ) { y += h; h = -h; } QPDFDBG( printf ( "DRAWING IMAGE MASKED: %d/%d - %dx%d\n", x, y, w, h )); img = img. smoothScale ( w, h ); qApp-> processEvents ( ); m_painter-> drawImage ( x, y, img ); } #endif delete imgStr; qApp-> processEvents ( ); } void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg ) { int nComps, nVals, nBits; // image parameters nComps = colorMap->getNumPixelComps ( ); nVals = width * nComps; nBits = colorMap-> getBits ( ); diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 52419ad..0459caf 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1,1010 +1,1010 @@ /* * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> * Released under the terms of the GNU GPL v2.0. */ #include <qapplication.h> #include <qmainwindow.h> #include <qtoolbar.h> #include <qvbox.h> #include <qsplitter.h> #include <qlistview.h> #include <qtextview.h> #include <qlineedit.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qaction.h> #include <qheader.h> #include <qfiledialog.h> #include <qregexp.h> -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 #include <qsettings.h> #endif #include <stdlib.h> #include "lkc.h" #include "qconf.h" #include "qconf.moc" #include "images.c" static QApplication *configApp; -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 static QSettings *configSettings; #endif /* * update all the children of a menu entry * removes/adds the entries from the parent widget as necessary * * parent: either the menu list widget or a menu entry widget * menu: entry to be updated */ template <class P> void ConfigList::updateMenuList(P* parent, struct menu* menu) { struct menu* child; ConfigItem* item; ConfigItem* last; bool visible; enum prop_type type; if (!menu) { while ((item = parent->firstChild())) delete item; return; } last = parent->firstChild(); if (last && !last->goParent) last = 0; for (child = menu->list; child; child = child->next) { item = last ? last->nextSibling() : parent->firstChild(); type = child->prompt ? child->prompt->type : P_UNKNOWN; switch (mode) { case menuMode: if (!(child->flags & MENU_ROOT)) goto hide; break; case symbolMode: if (child->flags & MENU_ROOT) goto hide; break; default: break; } visible = menu_is_visible(child); if (showAll || visible) { if (!item || item->menu != child) item = new ConfigItem(parent, last, child, visible); else item->testUpdateMenu(visible); if (mode == fullMode || mode == menuMode || type != P_MENU) updateMenuList(item, child); else updateMenuList(item, 0); last = item; continue; } hide: if (item && item->menu == child) { last = parent->firstChild(); if (last == item) last = 0; else while (last->nextSibling() != item) last = last->nextSibling(); delete item; } } } -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 /* * set the new data * TODO check the value */ void ConfigItem::okRename(int col) { Parent::okRename(col); sym_set_string_value(menu->sym, text(dataColIdx).latin1()); } #endif /* * update the displayed of a menu entry */ void ConfigItem::updateMenu(void) { ConfigList* list; struct symbol* sym; struct property *prop; QString prompt; int type; tristate expr; list = listView(); if (goParent) { setPixmap(promptColIdx, list->menuBackPix); prompt = ".."; goto set_prompt; } sym = menu->sym; prop = menu->prompt; prompt = menu_get_prompt(menu); if (prop) switch (prop->type) { case P_MENU: if (list->mode == singleMode || list->mode == symbolMode) { /* a menuconfig entry is displayed differently * depending whether it's at the view root or a child. */ if (sym && list->rootEntry == menu) break; setPixmap(promptColIdx, list->menuPix); } else { if (sym) break; setPixmap(promptColIdx, 0); } goto set_prompt; case P_COMMENT: setPixmap(promptColIdx, 0); goto set_prompt; default: ; } if (!sym) goto set_prompt; setText(nameColIdx, sym->name); type = sym_get_type(sym); switch (type) { case S_BOOLEAN: case S_TRISTATE: char ch; if (!sym_is_changable(sym) && !list->showAll) { setPixmap(promptColIdx, 0); setText(noColIdx, 0); setText(modColIdx, 0); setText(yesColIdx, 0); break; } expr = sym_get_tristate_value(sym); switch (expr) { case yes: if (sym_is_choice_value(sym) && type == S_BOOLEAN) setPixmap(promptColIdx, list->choiceYesPix); else setPixmap(promptColIdx, list->symbolYesPix); setText(yesColIdx, "Y"); ch = 'Y'; break; case mod: setPixmap(promptColIdx, list->symbolModPix); setText(modColIdx, "M"); ch = 'M'; break; default: if (sym_is_choice_value(sym) && type == S_BOOLEAN) setPixmap(promptColIdx, list->choiceNoPix); else setPixmap(promptColIdx, list->symbolNoPix); setText(noColIdx, "N"); ch = 'N'; break; } if (expr != no) setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); if (expr != mod) setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); if (expr != yes) setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); setText(dataColIdx, QChar(ch)); break; case S_INT: case S_HEX: case S_STRING: const char* data; data = sym_get_string_value(sym); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 int i = list->mapIdx(dataColIdx); if (i >= 0) setRenameEnabled(i, TRUE); #endif setText(dataColIdx, data); if (type == S_STRING) prompt.sprintf("%s: %s", prompt.latin1(), data); else prompt.sprintf("(%s) %s", data, prompt.latin1()); break; } if (!sym_has_value(sym) && visible) prompt += " (NEW)"; set_prompt: setText(promptColIdx, prompt); } void ConfigItem::testUpdateMenu(bool v) { ConfigItem* i; visible = v; if (!menu) return; sym_calc_value(menu->sym); if (menu->flags & MENU_CHANGED) { /* the menu entry changed, so update all list items */ menu->flags &= ~MENU_CHANGED; for (i = (ConfigItem*)menu->data; i; i = i->nextItem) i->updateMenu(); } else if (listView()->updateAll) updateMenu(); } void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) { ConfigList* list = listView(); if (visible) { if (isSelected() && !list->hasFocus() && list->mode == menuMode) Parent::paintCell(p, list->inactivedColorGroup, column, width, align); else Parent::paintCell(p, cg, column, width, align); } else Parent::paintCell(p, list->disabledColorGroup, column, width, align); } /* * construct a menu entry */ void ConfigItem::init(void) { if (menu) { ConfigList* list = listView(); nextItem = (ConfigItem*)menu->data; menu->data = this; if (list->mode != fullMode) setOpen(TRUE); sym_calc_value(menu->sym); } updateMenu(); } /* * destruct a menu entry */ ConfigItem::~ConfigItem(void) { if (menu) { ConfigItem** ip = (ConfigItem**)&menu->data; for (; *ip; ip = &(*ip)->nextItem) { if (*ip == this) { *ip = nextItem; break; } } } } void ConfigLineEdit::show(ConfigItem* i) { item = i; if (sym_get_string_value(item->menu->sym)) setText(sym_get_string_value(item->menu->sym)); else setText(0); Parent::show(); setFocus(); } void ConfigLineEdit::keyPressEvent(QKeyEvent* e) { switch (e->key()) { case Key_Escape: break; case Key_Return: case Key_Enter: sym_set_string_value(item->menu->sym, text().latin1()); parent()->updateList(item); break; default: Parent::keyPressEvent(e); return; } e->accept(); parent()->list->setFocus(); hide(); } ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv) : Parent(p), cview(cv), updateAll(false), symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), showAll(false), showName(false), showRange(false), showData(false), rootEntry(0) { int i; setSorting(-1); setRootIsDecorated(TRUE); disabledColorGroup = palette().active(); disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text()); inactivedColorGroup = palette().active(); inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight()); connect(this, SIGNAL(selectionChanged(void)), SLOT(updateSelection(void))); for (i = 0; i < colNr; i++) colMap[i] = colRevMap[i] = -1; addColumn(promptColIdx, "Option"); reinit(); } void ConfigList::reinit(void) { removeColumn(dataColIdx); removeColumn(yesColIdx); removeColumn(modColIdx); removeColumn(noColIdx); removeColumn(nameColIdx); if (showName) addColumn(nameColIdx, "Name"); if (showRange) { addColumn(noColIdx, "N"); addColumn(modColIdx, "M"); addColumn(yesColIdx, "Y"); } if (showData) addColumn(dataColIdx, "Value"); updateListAll(); } void ConfigList::updateSelection(void) { struct menu *menu; enum prop_type type; ConfigItem* item = (ConfigItem*)selectedItem(); if (!item) return; cview->setHelp(item); menu = item->menu; if (!menu) return; type = menu->prompt ? menu->prompt->type : P_UNKNOWN; if (mode == menuMode && type == P_MENU) emit menuSelected(menu); } void ConfigList::updateList(ConfigItem* item) { ConfigItem* last = 0; if (!rootEntry) goto update; if (rootEntry != &rootmenu && (mode == singleMode || (mode == symbolMode && rootEntry->parent != &rootmenu))) { item = firstChild(); if (!item) item = new ConfigItem(this, 0, true); last = item; } if (mode == singleMode && rootEntry->sym && rootEntry->prompt) { item = last ? last->nextSibling() : firstChild(); if (!item) item = new ConfigItem(this, last, rootEntry, true); updateMenuList(item, rootEntry); triggerUpdate(); return; } update: updateMenuList(this, rootEntry); triggerUpdate(); } void ConfigList::setAllOpen(bool open) { QListViewItemIterator it(this); for (; it.current(); it++) it.current()->setOpen(open); } void ConfigList::setValue(ConfigItem* item, tristate val) { struct symbol* sym; int type; tristate oldval; sym = item->menu ? item->menu->sym : 0; if (!sym) return; type = sym_get_type(sym); switch (type) { case S_BOOLEAN: case S_TRISTATE: oldval = sym_get_tristate_value(sym); if (!sym_set_tristate_value(sym, val)) return; if (oldval == no && item->menu->list) item->setOpen(TRUE); parent()->updateList(item); break; } } void ConfigList::changeValue(ConfigItem* item) { struct symbol* sym; struct menu* menu; int type, oldexpr, newexpr; menu = item->menu; if (!menu) return; sym = menu->sym; if (!sym) { if (item->menu->list) item->setOpen(!item->isOpen()); return; } type = sym_get_type(sym); switch (type) { case S_BOOLEAN: case S_TRISTATE: oldexpr = sym_get_tristate_value(sym); newexpr = sym_toggle_tristate_value(sym); if (item->menu->list) { if (oldexpr == newexpr) item->setOpen(!item->isOpen()); else if (oldexpr == no) item->setOpen(TRUE); } if (oldexpr != newexpr) parent()->updateList(item); break; case S_INT: case S_HEX: case S_STRING: -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (colMap[dataColIdx] >= 0) item->startRename(colMap[dataColIdx]); else #endif parent()->lineEdit->show(item); break; } } void ConfigList::setRootMenu(struct menu *menu) { enum prop_type type; if (rootEntry == menu) return; type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; if (type != P_MENU) return; updateMenuList(this, 0); rootEntry = menu; updateListAll(); setSelected(currentItem(), hasFocus()); } void ConfigList::setParentMenu(void) { ConfigItem* item; struct menu *oldroot; oldroot = rootEntry; if (rootEntry == &rootmenu) return; setRootMenu(menu_get_parent_menu(rootEntry->parent)); QListViewItemIterator it(this); for (; (item = (ConfigItem*)it.current()); it++) { if (item->menu == oldroot) { setCurrentItem(item); ensureItemVisible(item); break; } } } void ConfigList::keyPressEvent(QKeyEvent* ev) { QListViewItem* i = currentItem(); ConfigItem* item; struct menu *menu; enum prop_type type; if (ev->key() == Key_Escape && mode != fullMode) { emit parentSelected(); ev->accept(); return; } if (!i) { Parent::keyPressEvent(ev); return; } item = (ConfigItem*)i; switch (ev->key()) { case Key_Return: case Key_Enter: if (item->goParent) { emit parentSelected(); break; } menu = item->menu; if (!menu) break; type = menu->prompt ? menu->prompt->type : P_UNKNOWN; if (type == P_MENU && rootEntry != menu && mode != fullMode && mode != menuMode) { emit menuSelected(menu); break; } case Key_Space: changeValue(item); break; case Key_N: setValue(item, no); break; case Key_M: setValue(item, mod); break; case Key_Y: setValue(item, yes); break; default: Parent::keyPressEvent(ev); return; } ev->accept(); } void ConfigList::contentsMousePressEvent(QMouseEvent* e) { //QPoint p(contentsToViewport(e->pos())); //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); Parent::contentsMousePressEvent(e); } void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) { QPoint p(contentsToViewport(e->pos())); ConfigItem* item = (ConfigItem*)itemAt(p); struct menu *menu; enum prop_type ptype; const QPixmap* pm; int idx, x; if (!item) goto skip; menu = item->menu; x = header()->offset() + p.x(); idx = colRevMap[header()->sectionAt(x)]; switch (idx) { case promptColIdx: pm = item->pixmap(promptColIdx); if (pm) { int off = header()->sectionPos(0) + itemMargin() + treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); if (x >= off && x < off + pm->width()) { if (item->goParent) { emit parentSelected(); break; } else if (!menu) break; ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; if (ptype == P_MENU && rootEntry != menu && mode != fullMode && mode != menuMode) emit menuSelected(menu); else changeValue(item); } } break; case noColIdx: setValue(item, no); break; case modColIdx: setValue(item, mod); break; case yesColIdx: setValue(item, yes); break; case dataColIdx: changeValue(item); break; } skip: //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); Parent::contentsMouseReleaseEvent(e); } void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) { //QPoint p(contentsToViewport(e->pos())); //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); Parent::contentsMouseMoveEvent(e); } void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) { QPoint p(contentsToViewport(e->pos())); ConfigItem* item = (ConfigItem*)itemAt(p); struct menu *menu; enum prop_type ptype; if (!item) goto skip; if (item->goParent) { emit parentSelected(); goto skip; } menu = item->menu; if (!menu) goto skip; ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; if (ptype == P_MENU && (mode == singleMode || mode == symbolMode)) emit menuSelected(menu); else if (menu->sym) changeValue(item); skip: //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); Parent::contentsMouseDoubleClickEvent(e); } void ConfigList::focusInEvent(QFocusEvent *e) { Parent::focusInEvent(e); QListViewItem* item = currentItem(); if (!item) return; setSelected(item, TRUE); emit gotFocus(); } ConfigView* ConfigView::viewList; ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview) : Parent(parent) { list = new ConfigList(this, cview); lineEdit = new ConfigLineEdit(this); lineEdit->hide(); this->nextView = viewList; viewList = this; } ConfigView::~ConfigView(void) { ConfigView** vp; for (vp = &viewList; *vp; vp = &(*vp)->nextView) { if (*vp == this) { *vp = nextView; break; } } } void ConfigView::updateList(ConfigItem* item) { ConfigView* v; for (v = viewList; v; v = v->nextView) v->list->updateList(item); } void ConfigView::updateListAll(void) { ConfigView* v; for (v = viewList; v; v = v->nextView) v->list->updateListAll(); } /* * Construct the complete config widget */ ConfigMainWindow::ConfigMainWindow(void) { QMenuBar* menu; QSplitter* split1; QSplitter* split2; bool ok; int x, y, width, height; QWidget *d = configApp->desktop(); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64); height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64); resize(width, height); x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok); if (ok) y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok); if (ok) move(x, y); #else width = d->width() - 64; height = d->height() - 64; resize(width, height); #endif showDebug = false; split1 = new QSplitter(this); split1->setOrientation(QSplitter::Horizontal); setCentralWidget(split1); menuView = new ConfigView(split1, this); menuList = menuView->list; split2 = new QSplitter(split1); split2->setOrientation(QSplitter::Vertical); // create config tree configView = new ConfigView(split2, this); configList = configView->list; helpText = new QTextView(split2); helpText->setTextFormat(Qt::RichText); setTabOrder(configList, helpText); configList->setFocus(); menu = menuBar(); toolBar = new QToolBar("Tools", this); backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this); connect(backAction, SIGNAL(activated()), SLOT(goBack())); backAction->setEnabled(FALSE); QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this); connect(quitAction, SIGNAL(activated()), SLOT(close())); QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this); connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); showNameAction->setToggleAction(TRUE); showNameAction->setOn(configList->showName); connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool))); QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); showRangeAction->setToggleAction(TRUE); showRangeAction->setOn(configList->showRange); connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool))); QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); showDataAction->setToggleAction(TRUE); showDataAction->setOn(configList->showData); connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool))); QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); showAllAction->setToggleAction(TRUE); showAllAction->setOn(configList->showAll); connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool))); QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); showDebugAction->setToggleAction(TRUE); showDebugAction->setOn(showDebug); connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this); connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); QAction *showAboutAction = new QAction(NULL, "About", 0, this); connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); // init tool bar backAction->addTo(toolBar); toolBar->addSeparator(); loadAction->addTo(toolBar); saveAction->addTo(toolBar); toolBar->addSeparator(); singleViewAction->addTo(toolBar); splitViewAction->addTo(toolBar); fullViewAction->addTo(toolBar); // create config menu QPopupMenu* config = new QPopupMenu(this); menu->insertItem("&File", config); loadAction->addTo(config); saveAction->addTo(config); saveAsAction->addTo(config); config->insertSeparator(); quitAction->addTo(config); // create options menu QPopupMenu* optionMenu = new QPopupMenu(this); menu->insertItem("&Option", optionMenu); showNameAction->addTo(optionMenu); showRangeAction->addTo(optionMenu); showDataAction->addTo(optionMenu); optionMenu->insertSeparator(); showAllAction->addTo(optionMenu); showDebugAction->addTo(optionMenu); // create help menu QPopupMenu* helpMenu = new QPopupMenu(this); menu->insertSeparator(); menu->insertItem("&Help", helpMenu); showIntroAction->addTo(helpMenu); showAboutAction->addTo(helpMenu); connect(configList, SIGNAL(menuSelected(struct menu *)), SLOT(changeMenu(struct menu *))); connect(configList, SIGNAL(parentSelected()), SLOT(goBack())); connect(menuList, SIGNAL(menuSelected(struct menu *)), SLOT(changeMenu(struct menu *))); connect(configList, SIGNAL(gotFocus(void)), SLOT(listFocusChanged(void))); connect(menuList, SIGNAL(gotFocus(void)), SLOT(listFocusChanged(void))); showSplitView(); } static QString print_filter(const char *str) { QRegExp re("[<>&\"\\n]"); QString res = str; for (int i = 0; (i = res.find(re, i)) >= 0;) { switch (res[i].latin1()) { case '<': res.replace(i, 1, "<"); i += 4; break; case '>': res.replace(i, 1, ">"); i += 4; break; case '&': res.replace(i, 1, "&"); i += 5; break; case '"': res.replace(i, 1, """); i += 6; break; case '\n': res.replace(i, 1, "<br>"); i += 4; break; } } return res; } static void expr_print_help(void *data, const char *str) { ((QString*)data)->append(print_filter(str)); } /* * display a new help entry as soon as a new menu entry is selected */ void ConfigMainWindow::setHelp(QListViewItem* item) { struct symbol* sym; struct menu* menu = 0; configList->parent()->lineEdit->hide(); if (item) menu = ((ConfigItem*)item)->menu; if (!menu) { helpText->setText(NULL); return; } QString head, debug, help; menu = ((ConfigItem*)item)->menu; sym = menu->sym; if (sym) { if (menu->prompt) { head += "<big><b>"; head += print_filter(menu->prompt->text); head += "</b></big>"; if (sym->name) { head += " ("; head += print_filter(sym->name); head += ")"; } } else if (sym->name) { head += "<big><b>"; head += print_filter(sym->name); head += "</b></big>"; } head += "<br><br>"; if (showDebug) { debug += "type: "; debug += print_filter(sym_type_name(sym->type)); if (sym_is_choice(sym)) debug += " (choice)"; debug += "<br>"; if (sym->rev_dep.expr) { debug += "reverse dep: "; expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); debug += "<br>"; } for (struct property *prop = sym->prop; prop; prop = prop->next) { switch (prop->type) { case P_PROMPT: case P_MENU: debug += "prompt: "; debug += print_filter(prop->text); debug += "<br>"; break; case P_DEFAULT: debug += "default: "; expr_print(prop->expr, expr_print_help, &debug, E_NONE); debug += "<br>"; break; case P_CHOICE: if (sym_is_choice(sym)) { debug += "choice: "; expr_print(prop->expr, expr_print_help, &debug, E_NONE); debug += "<br>"; } break; case P_SELECT: debug += "select: "; expr_print(prop->expr, expr_print_help, &debug, E_NONE); debug += "<br>"; break; case P_RANGE: debug += "range: "; expr_print(prop->expr, expr_print_help, &debug, E_NONE); debug += "<br>"; break; default: debug += "unknown property: "; debug += prop_get_type_name(prop->type); debug += "<br>"; } if (prop->visible.expr) { debug += " dep: "; expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); debug += "<br>"; @@ -1013,292 +1013,292 @@ void ConfigMainWindow::setHelp(QListViewItem* item) debug += "<br>"; } help = print_filter(sym->help); } else if (menu->prompt) { head += "<big><b>"; head += print_filter(menu->prompt->text); head += "</b></big><br><br>"; if (showDebug) { if (menu->prompt->visible.expr) { debug += " dep: "; expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); debug += "<br><br>"; } } } if (showDebug) debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno); helpText->setText(head + debug + help); } void ConfigMainWindow::loadConfig(void) { QString s = QFileDialog::getOpenFileName(".config", NULL, this); if (s.isNull()) return; if (conf_read(s.latin1())) QMessageBox::information(this, "qconf", "Unable to load configuration!"); ConfigView::updateListAll(); } void ConfigMainWindow::saveConfig(void) { if (conf_write(NULL)) QMessageBox::information(this, "qconf", "Unable to save configuration!"); } void ConfigMainWindow::saveConfigAs(void) { QString s = QFileDialog::getSaveFileName(".config", NULL, this); if (s.isNull()) return; if (conf_write(s.latin1())) QMessageBox::information(this, "qconf", "Unable to save configuration!"); } void ConfigMainWindow::changeMenu(struct menu *menu) { configList->setRootMenu(menu); backAction->setEnabled(TRUE); } void ConfigMainWindow::listFocusChanged(void) { if (menuList->hasFocus()) { if (menuList->mode == menuMode) configList->clearSelection(); setHelp(menuList->selectedItem()); } else if (configList->hasFocus()) { setHelp(configList->selectedItem()); } } void ConfigMainWindow::goBack(void) { ConfigItem* item; configList->setParentMenu(); if (configList->rootEntry == &rootmenu) backAction->setEnabled(FALSE); item = (ConfigItem*)menuList->selectedItem(); while (item) { if (item->menu == configList->rootEntry) { menuList->setSelected(item, TRUE); break; } item = (ConfigItem*)item->parent(); } } void ConfigMainWindow::showSingleView(void) { menuView->hide(); menuList->setRootMenu(0); configList->mode = singleMode; if (configList->rootEntry == &rootmenu) configList->updateListAll(); else configList->setRootMenu(&rootmenu); configList->setAllOpen(TRUE); configList->setFocus(); } void ConfigMainWindow::showSplitView(void) { configList->mode = symbolMode; if (configList->rootEntry == &rootmenu) configList->updateListAll(); else configList->setRootMenu(&rootmenu); configList->setAllOpen(TRUE); configApp->processEvents(); menuList->mode = menuMode; menuList->setRootMenu(&rootmenu); menuList->setAllOpen(TRUE); menuView->show(); menuList->setFocus(); } void ConfigMainWindow::showFullView(void) { menuView->hide(); menuList->setRootMenu(0); configList->mode = fullMode; if (configList->rootEntry == &rootmenu) configList->updateListAll(); else configList->setRootMenu(&rootmenu); configList->setAllOpen(FALSE); configList->setFocus(); } void ConfigMainWindow::setShowAll(bool b) { if (configList->showAll == b) return; configList->showAll = b; configList->updateListAll(); menuList->showAll = b; menuList->updateListAll(); } void ConfigMainWindow::setShowDebug(bool b) { if (showDebug == b) return; showDebug = b; } void ConfigMainWindow::setShowName(bool b) { if (configList->showName == b) return; configList->showName = b; configList->reinit(); menuList->showName = b; menuList->reinit(); } void ConfigMainWindow::setShowRange(bool b) { if (configList->showRange == b) return; configList->showRange = b; configList->reinit(); menuList->showRange = b; menuList->reinit(); } void ConfigMainWindow::setShowData(bool b) { if (configList->showData == b) return; configList->showData = b; configList->reinit(); menuList->showData = b; menuList->reinit(); } /* * ask for saving configuration before quitting * TODO ask only when something changed */ void ConfigMainWindow::closeEvent(QCloseEvent* e) { if (!sym_change_count) { e->accept(); return; } QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); mb.setButtonText(QMessageBox::Yes, "&Save Changes"); mb.setButtonText(QMessageBox::No, "&Discard Changes"); mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); switch (mb.exec()) { case QMessageBox::Yes: conf_write(NULL); case QMessageBox::No: e->accept(); break; case QMessageBox::Cancel: e->ignore(); break; } } void ConfigMainWindow::showIntro(void) { static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" "For each option, a blank box indicates the feature is disabled, a check\n" "indicates it is enabled, and a dot indicates that it is to be compiled\n" "as a module. Clicking on the box will cycle through the three states.\n\n" "If you do not see an option (e.g., a device driver) that you believe\n" "should be present, try turning on Show All Options under the Options menu.\n" "Although there is no cross reference yet to help you figure out what other\n" "options must be enabled to support the option you are interested in, you can\n" "still view the help of a grayed-out option.\n\n" "Toggling Show Debug Info under the Options menu will show the dependencies,\n" "which you can then match by examining other options.\n\n"; QMessageBox::information(this, "qconf", str); } void ConfigMainWindow::showAbout(void) { static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n" "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; QMessageBox::information(this, "qconf", str); } void fixup_rootmenu(struct menu *menu) { struct menu *child; static int menu_cnt = 0; menu->flags |= MENU_ROOT; for (child = menu->list; child; child = child->next) { if (child->prompt && child->prompt->type == P_MENU) { menu_cnt++; fixup_rootmenu(child); menu_cnt--; } else if (!menu_cnt) fixup_rootmenu(child); } } static const char *progname; static void usage(void) { printf("%s <config>\n", progname); exit(0); } int main(int ac, char** av) { ConfigMainWindow* v; const char *name; #ifndef LKC_DIRECT_LINK kconfig_load(); #endif progname = av[0]; configApp = new QApplication(ac, av); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 configSettings = new QSettings; #endif if (ac > 1 && av[1][0] == '-') { switch (av[1][1]) { case 'h': case '?': usage(); } name = av[2]; } else name = av[1]; if (!name) usage(); conf_parse(name); fixup_rootmenu(&rootmenu); conf_read(NULL); //zconfdump(stdout); v = new ConfigMainWindow(); //zconfdump(stdout); v->show(); configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); configApp->exec(); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 configSettings->writeEntry("/kconfig/qconf/window x", v->pos().x()); configSettings->writeEntry("/kconfig/qconf/window y", v->pos().y()); configSettings->writeEntry("/kconfig/qconf/window width", v->size().width()); configSettings->writeEntry("/kconfig/qconf/window height", v->size().height()); delete configSettings; #endif return 0; } diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index c548884..dee5254 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -1,238 +1,238 @@ /* * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> * Released under the terms of the GNU GPL v2.0. */ #include <qlistview.h> class ConfigList; class ConfigItem; class ConfigLineEdit; class ConfigMainWindow; class ConfigView : public QVBox { Q_OBJECT typedef class QVBox Parent; public: ConfigView(QWidget* parent, ConfigMainWindow* cview); ~ConfigView(void); static void updateList(ConfigItem* item); static void updateListAll(void); public: ConfigList* list; ConfigLineEdit* lineEdit; static ConfigView* viewList; ConfigView* nextView; }; enum colIdx { promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr }; enum listMode { singleMode, menuMode, symbolMode, fullMode }; class ConfigList : public QListView { Q_OBJECT typedef class QListView Parent; public: ConfigList(ConfigView* p, ConfigMainWindow* cview); void reinit(void); ConfigView* parent(void) const { return (ConfigView*)Parent::parent(); } protected: ConfigMainWindow* cview; void keyPressEvent(QKeyEvent *e); void contentsMousePressEvent(QMouseEvent *e); void contentsMouseReleaseEvent(QMouseEvent *e); void contentsMouseMoveEvent(QMouseEvent *e); void contentsMouseDoubleClickEvent(QMouseEvent *e); void focusInEvent(QFocusEvent *e); public slots: void setRootMenu(struct menu *menu); void updateList(ConfigItem *item); void setValue(ConfigItem* item, tristate val); void changeValue(ConfigItem* item); void updateSelection(void); signals: void menuSelected(struct menu *menu); void parentSelected(void); void gotFocus(void); public: void updateListAll(void) { updateAll = true; updateList(NULL); updateAll = false; } ConfigList* listView() { return this; } ConfigItem* firstChild() const { return (ConfigItem *)Parent::firstChild(); } int mapIdx(colIdx idx) { return colMap[idx]; } void addColumn(colIdx idx, const QString& label) { colMap[idx] = Parent::addColumn(label); colRevMap[colMap[idx]] = idx; } void removeColumn(colIdx idx) { int col = colMap[idx]; if (col >= 0) { Parent::removeColumn(col); colRevMap[col] = colMap[idx] = -1; } } void setAllOpen(bool open); void setParentMenu(void); template <class P> void ConfigList::updateMenuList(P*, struct menu*); bool updateAll; QPixmap symbolYesPix, symbolModPix, symbolNoPix; QPixmap choiceYesPix, choiceNoPix; QPixmap menuPix, menuInvPix, menuBackPix, voidPix; bool showAll, showName, showRange, showData; enum listMode mode; struct menu *rootEntry; QColorGroup disabledColorGroup; QColorGroup inactivedColorGroup; private: int colMap[colNr]; int colRevMap[colNr]; }; class ConfigItem : public QListViewItem { typedef class QListViewItem Parent; public: ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v) : Parent(parent, after), menu(m), visible(v), goParent(false) { init(); } ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) : Parent(parent, after), menu(m), visible(v), goParent(false) { init(); } ConfigItem(QListView *parent, ConfigItem *after, bool v) : Parent(parent, after), menu(0), visible(v), goParent(true) { init(); } ~ConfigItem(void); void init(void); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 void okRename(int col); #endif void updateMenu(void); void testUpdateMenu(bool v); ConfigList* listView() const { return (ConfigList*)Parent::listView(); } ConfigItem* firstChild() const { return (ConfigItem *)Parent::firstChild(); } ConfigItem* nextSibling() const { return (ConfigItem *)Parent::nextSibling(); } void setText(colIdx idx, const QString& text) { Parent::setText(listView()->mapIdx(idx), text); } QString text(colIdx idx) const { return Parent::text(listView()->mapIdx(idx)); } void setPixmap(colIdx idx, const QPixmap& pm) { Parent::setPixmap(listView()->mapIdx(idx), pm); } const QPixmap* pixmap(colIdx idx) const { return Parent::pixmap(listView()->mapIdx(idx)); } void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); ConfigItem* nextItem; struct menu *menu; bool visible; bool goParent; }; class ConfigLineEdit : public QLineEdit { Q_OBJECT typedef class QLineEdit Parent; public: ConfigLineEdit(ConfigView* parent) : Parent(parent) { } ConfigView* parent(void) const { return (ConfigView*)Parent::parent(); } void show(ConfigItem *i); void keyPressEvent(QKeyEvent *e); public: ConfigItem *item; }; class ConfigMainWindow : public QMainWindow { Q_OBJECT public: ConfigMainWindow(void); public slots: void setHelp(QListViewItem* item); void changeMenu(struct menu *); void listFocusChanged(void); void goBack(void); void loadConfig(void); void saveConfig(void); void saveConfigAs(void); void showSingleView(void); void showSplitView(void); void showFullView(void); void setShowAll(bool); void setShowDebug(bool); void setShowRange(bool); void setShowName(bool); void setShowData(bool); void showIntro(void); void showAbout(void); protected: void closeEvent(QCloseEvent *e); ConfigView *menuView; ConfigList *menuList; ConfigView *configView; ConfigList *configList; QTextView *helpText; QToolBar *toolBar; QAction *backAction; bool showDebug; }; |