void ProgressBar::paintEvent( QPaintEvent* e ) { QFrame::paintEvent( e ); QPainter p( this ); StopWatch* sw = ScrobbleService::instance().stopWatch(); if ( m_track != Track() ) { QFont timeFont = font(); timeFont.setPixelSize( 10 ); setFont( timeFont ); p.setPen( QColor( 0x333333 ) ); if ( m_track.extra( "playerId" ) != "spt" ) { if ( m_track.duration() >= 30 ) { QString format( "m:ss" ); QTime duration( 0, 0 ); duration = duration.addMSecs( m_track.duration() * 1000 ); QTime progress( 0, 0 ); progress = progress.addMSecs( m_frame ); if ( duration.hour() > 0 ) format = "h:mm:ss"; QTextOption timeTextOption; timeTextOption.setAlignment( Qt::AlignVCenter | Qt::AlignLeft ); QString timeText; if ( m_track.source() == Track::LastFmRadio ) timeText = QString( "%1 / %2" ).arg( progress.toString( format ), duration.toString( format ) ); else timeText = QString( "%1" ).arg( progress.toString( format ) ); p.setPen( QColor( 0x333333 ) ); p.drawText( rect().adjusted( 6, 0, 0, 0 ), timeText, timeTextOption ); QFontMetrics fm( font() ); int indent = fm.width( timeText ) + ( 2 * 6 ) + 2; int width = this->width() - indent; p.setPen( QColor( 0xbdbdbd )); p.drawLine( QPoint( indent - 2, rect().top() ), QPoint( indent - 2, rect().bottom() - 1 ) ); p.setPen( QColor( 0xe6e6e6 ) ); p.drawLine( QPoint( indent - 1, rect().top() ), QPoint( indent - 1, rect().bottom() - 1 ) ); // draw the chunk p.setPen( Qt::transparent ); p.setBrush( m_chunk ); p.drawRect( rect().adjusted( indent, 0, ((m_frame * width) / (m_track.duration() * 1000)) - width, -1) ); //bool scrobblingOn = unicorn::UserSettings().value( "scrobblingOn", true ).toBool(); bool scrobblingOn = ScrobbleService::instance().scrobblableTrack( m_track ); if ( scrobblingOn || !scrobblingOn && m_track.scrobbleStatus() != Track::Null ) { if ( !scrobblingOn && m_track.scrobbleStatus() != Track::Null ) { QTextOption textOption; textOption.setAlignment( Qt::AlignVCenter | Qt::AlignRight ); p.drawText( rect().adjusted( 0, 0, -6, 0 ), tr( "Scrobbling off" ), textOption ); } uint scrobblePoint = sw->scrobblePoint() * 1000; int scrobbleMarker = indent + (scrobblePoint * width) / ( m_track.duration() * 1000 ); p.setPen( QPen( QColor( 0xbdbdbd ), 1, Qt::DotLine) ); p.drawLine( QPoint( scrobbleMarker - 1, rect().top() ), QPoint( scrobbleMarker - 1, rect().bottom() ) ); p.setPen( QPen( QColor( 0xe6e6e6 ), 1, Qt::DotLine) ); p.drawLine( QPoint( scrobbleMarker, rect().top() ), QPoint( scrobbleMarker, rect().bottom() ) ); // Draw the 'as'! // if the scrobble marker is too close to the left draw the 'as' on the right hand side QPoint asPoint; QImage as( m_track.scrobbleStatus() != Track::Null ? m_scrobbleMarkerOn : m_scrobbleMarkerOff ); if ( ( as.width() + 10 ) > scrobbleMarker - indent ) asPoint = QPoint ( scrobbleMarker + 5 , (rect().height() / 2) - (as.height() / 2) ); else asPoint = QPoint ( scrobbleMarker - as.width() - 5, (rect().height() / 2) - (as.height() / 2) ); p.drawImage( asPoint, as ); } else { QString offMessage = NULL; if ( unicorn::UserSettings().value( "scrobblingOn", true ).toBool() ) { if ( m_track.isVideo() ) offMessage = tr( "Not scrobbling - not a music video" ); else if ( !unicorn::UserSettings().value( "podcasts", true ).toBool() && m_track.isPodcast() ) offMessage = tr( "Not scrobbling - podcasts disabled" ); else if ( m_track.artist().isNull() ) offMessage = tr( "Not scrobbling - missing artist" ); } if(offMessage != NULL) { p.setPen( QColor( 0x333333 ) ); QTextOption textOption; textOption.setAlignment( Qt::AlignVCenter | Qt::AlignRight ); p.drawText( rect().adjusted( 0, 0, -6, 0 ), offMessage, textOption ); } } } else { QTextOption textOption; textOption.setAlignment( Qt::AlignVCenter | Qt::AlignRight ); p.drawText( rect().adjusted( 0, 0, -6, 0 ), tr( "Not scrobbling - track too short" ), textOption ); } } else { QTextOption textOption; textOption.setAlignment( Qt::AlignVCenter | Qt::AlignRight ); p.drawText( rect().adjusted( 0, 0, -6, 0 ), tr("Enable scrobbling in Spotify's preferences!"), textOption ); } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // QString s = QString::number(colors[1][0]); // ui->textEdit->append(s); // colors = new int*[12]; // for(int i = 0; i < 12; ++i){ // colors[i] = new int[3]; // } connect(ui->italic,SIGNAL(clicked()),this,SLOT(setItalic())); connect(ui->underline,SIGNAL(clicked()),this,SLOT(setUnderline())); connect(ui->bold,SIGNAL(clicked()),this,SLOT(setBold())); connect(ui->sizebox,SIGNAL(currentIndexChanged(int)),this,SLOT(setSize(int))); connect(ui->alignLeft,SIGNAL(clicked()),this,SLOT(setAlignLeft())); connect(ui->alignCenter,SIGNAL(clicked()),this,SLOT(setAlignCenter())); connect(ui->alignRight,SIGNAL(clicked()),this,SLOT(setAlignRight())); connect(ui->justify,SIGNAL(clicked()),this,SLOT(setJustify())); // connect(ui->foregroundCombo,SIGNAL(clicked()),this,SLOT(colorHandle())); //connect(ui->backColorChooser,SIGNAL(clicked()),this,SLOT(backColorHandle())); connect(ui->fontComboBox,SIGNAL(currentFontChanged(QFont)),this,SLOT(setFont(QFont))); connect(ui->menuEdit,SIGNAL(triggered()),this,SLOT(enablePasteee())); connect(ui->menuEdit,SIGNAL(clicked()),this,SLOT(enablePasteee())); connect(ui->menuEdit,SIGNAL(hovered()),this,SLOT(enablePasteee())); connect(ui->actionUndo,SIGNAL(triggered()),this,SLOT(undo())); connect(ui->actionREdo,SIGNAL(triggered()),this,SLOT(redo())); connect(ui->actionCopy,SIGNAL(triggered()),this,SLOT(copy())); connect(ui->actionCut,SIGNAL(triggered()),this,SLOT(cut())); connect(ui->actionPaste_2,SIGNAL(triggered()),this,SLOT(paste())); connect(ui->actionLoad,SIGNAL(triggered()),this,SLOT(load())); connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(save())); connect(ui->actionSelectAll,SIGNAL(triggered()),this,SLOT(selectAll())); connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(exit())); QIcon *i0 = new QIcon(":/new/colors/0.png"); QIcon *i1 = new QIcon(":/new/colors/1.png"); QIcon *i2 = new QIcon(":/new/colors/2.png"); QIcon *i3 = new QIcon(":/new/colors/3.png"); QIcon *i4 = new QIcon(":/new/colors/4.png"); QIcon *i5 = new QIcon(":/new/colors/5.png"); QIcon *i6 = new QIcon(":/new/colors/6.png"); QIcon *i7 = new QIcon(":/new/colors/7.png"); QIcon *i8 = new QIcon(":/new/colors/8.png"); QIcon *i9 = new QIcon(":/new/colors/9.png"); QIcon *i10 = new QIcon(":/new/colors/10.png"); QIcon *i11 = new QIcon(":/new/colors/11.png"); QIcon *i12 = new QIcon(":/new/colors/12.png"); QIcon *i13 = new QIcon(":/new/colors/13.png"); QIcon *i14 = new QIcon(":/new/colors/14.png"); QIcon *i15 = new QIcon(":/new/colors/15.png"); QIcon *i16 = new QIcon(":/new/colors/16.png"); ui->foregroundCombo->setItemIcon(0,*i0); ui->foregroundCombo->setItemIcon(1,*i1); ui->foregroundCombo->setItemIcon(2,*i2); ui->foregroundCombo->setItemIcon(3,*i3); ui->foregroundCombo->setItemIcon(4,*i4); ui->foregroundCombo->setItemIcon(5,*i5); ui->foregroundCombo->setItemIcon(6,*i6); ui->foregroundCombo->setItemIcon(7,*i7); ui->foregroundCombo->setItemIcon(8,*i8); ui->foregroundCombo->setItemIcon(9,*i9); ui->foregroundCombo->setItemIcon(10,*i10); ui->foregroundCombo->setItemIcon(11,*i11); ui->foregroundCombo->setItemIcon(12,*i12); ui->foregroundCombo->setItemIcon(13,*i13); ui->foregroundCombo->setItemIcon(14,*i14); ui->foregroundCombo->setItemIcon(15,*i15); ui->foregroundCombo->setItemIcon(16,*i16); //---------------------------------------------------- ui->backgroundCombo->setItemIcon(0,*i16); ui->backgroundCombo->setItemIcon(1,*i0); ui->backgroundCombo->setItemIcon(2,*i1); ui->backgroundCombo->setItemIcon(3,*i2); ui->backgroundCombo->setItemIcon(4,*i3); ui->backgroundCombo->setItemIcon(5,*i4); ui->backgroundCombo->setItemIcon(6,*i5); ui->backgroundCombo->setItemIcon(7,*i6); ui->backgroundCombo->setItemIcon(8,*i7); ui->backgroundCombo->setItemIcon(9,*i8); ui->backgroundCombo->setItemIcon(10,*i9); ui->backgroundCombo->setItemIcon(11,*i10); ui->backgroundCombo->setItemIcon(12,*i11); ui->backgroundCombo->setItemIcon(13,*i12); ui->backgroundCombo->setItemIcon(14,*i13); ui->backgroundCombo->setItemIcon(15,*i14); ui->backgroundCombo->setItemIcon(16,*i15); // QPixmap pixmap3(":/Editing-Align-Left-icon.png"); // QIcon leftIcon(pixmap3); // ui->alignLeft->setIcon(leftIcon); // ui->alignLeft->setIconSize(QSize(25,25)); saved = false; foregroundColor=Qt::black; backgroundColor=Qt::white; QIcon *if0 = new QIcon(":/new/colors/0f.png"); QIcon *ib0 = new QIcon(":/new/colors/16b.png"); ui->forecolor->setIcon(*if0); ui->backcolor->setIcon(*ib0); fileName =""; }
void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, float e, float positionAngle) { float x = pos.x(); float y = pos.y(); float zoom = Options::zoomFactor(); int isize = int(size); float dx1 = -0.5*size; float dx2 = 0.5*size; float dy1 = -1.0*e*size/2.; float dy2 = e*size/2.; float x1 = x + dx1; float x2 = x + dx2; float y1 = y + dy1; float y2 = y + dy2; float dxa = -size/4.; float dxb = size/4.; float dya = -1.0*e*size/4.; float dyb = e*size/4.; float xa = x + dxa; float xb = x + dxb; float ya = y + dya; float yb = y + dyb; QString color; float psize; QBrush tempBrush; std::function<void( float, float, float, float )> lambdaDrawEllipse; std::function<void( float, float, float, float )> lambdaDrawLine; std::function<void( float, float, float, float )> lambdaDrawCross; if ( Options::useAntialias() ) { lambdaDrawEllipse = [this]( float x, float y, float width, float height ) { drawEllipse( QRectF( x, y, width, height ) ); }; lambdaDrawLine = [this]( float x1, float y1, float x2, float y2 ) { drawLine( QLineF( x1, y1, x2, y2 ) ); }; lambdaDrawCross = [this]( float centerX, float centerY, float sizeX, float sizeY ) { drawLine( QLineF( centerX - sizeX/2., centerY, centerX + sizeX/2., centerY ) ); drawLine( QLineF( centerX, centerY - sizeY/2., centerX, centerY + sizeY/2. ) ); }; } else { lambdaDrawEllipse = [this]( float x, float y, float width, float height ) { drawEllipse( QRect( x, y, width, height ) ); }; lambdaDrawLine = [this]( float x1, float y1, float x2, float y2 ) { drawLine( QLine( x1, y1, x2, y2 ) ); }; lambdaDrawCross = [this]( float centerX, float centerY, float sizeX, float sizeY ) { drawLine( QLine( centerX - sizeX/2., centerY, centerX + sizeX/2., centerY ) ); drawLine( QLine( centerX, centerY - sizeY/2., centerX, centerY + sizeY/2. ) ); }; } switch ( type ) { case 0: case 1: //catalog star //Some NGC/IC objects are stars...changed their type to 1 (was double star) if (size<2.) size = 2.; lambdaDrawEllipse( x1, y1, size/2., size/2. ); break; case 2: //Planet break; case 3: //Open cluster; draw circle of points case 13: { // Asterism tempBrush = brush(); color = pen().color().name(); setBrush( pen().color() ); psize = 2.; if ( size > 50. ) psize *= 2.; if ( size > 100. ) psize *= 2.; auto putDot = [this, psize, &lambdaDrawEllipse]( float x, float y ) { lambdaDrawEllipse( x, y, psize, psize ); }; putDot( xa, y1 ); putDot( xb, y1 ); putDot( xa, y2 ); putDot( xb, y2 ); putDot( x1, ya ); putDot( x1, yb ); putDot( x2, ya ); putDot( x2, yb ); setBrush( tempBrush ); break; } case 4: //Globular Cluster if (size<2.) size = 2.; save(); translate( x, y ); color = pen().color().name(); rotate( positionAngle ); //rotate the coordinate system lambdaDrawEllipse( dx1, dy1, size, e*size ); lambdaDrawCross( 0, 0, size, e*size ); restore(); //reset coordinate system break; case 5: //Gaseous Nebula case 15: // Dark Nebula if (size <2.) size = 2.; save(); translate( x, y ); rotate( positionAngle ); //rotate the coordinate system color = pen().color().name(); lambdaDrawLine( dx1, dy1, dx2, dy1 ); lambdaDrawLine( dx2, dy1, dx2, dy2 ); lambdaDrawLine( dx2, dy2, dx1, dy2 ); lambdaDrawLine( dx1, dy2, dx1, dy1 ); restore(); //reset coordinate system break; case 6: //Planetary Nebula if (size<2.) size = 2.; save(); translate( x, y ); rotate( positionAngle ); //rotate the coordinate system color = pen().color().name(); lambdaDrawEllipse( dx1, dy1, size, e*size ); lambdaDrawLine( 0., dy1, 0., dy1 - e*size/2. ); lambdaDrawLine( 0., dy2, 0., dy2 + e*size/2. ); lambdaDrawLine( dx1, 0., dx1 - size/2., 0. ); lambdaDrawLine( dx2, 0., dx2 + size/2., 0. ); restore(); //reset coordinate system break; case 7: //Supernova remnant // FIXME: Why is SNR drawn different from a gaseous nebula? if (size<2) size = 2; save(); translate( x, y ); rotate( positionAngle ); //rotate the coordinate system color = pen().color().name(); lambdaDrawLine( 0., dy1, dx2, 0. ); lambdaDrawLine( dx2, 0., 0., dy2 ); lambdaDrawLine( 0., dy2, dx1, 0. ); lambdaDrawLine( dx1, 0., 0., dy1 ); restore(); //reset coordinate system break; case 8: //Galaxy case 16: // Quasar color = pen().color().name(); if ( size <1. && zoom > 20*MINZOOM ) size = 3.; //force ellipse above zoomFactor 20 if ( size <1. && zoom > 5*MINZOOM ) size = 1.; //force points above zoomFactor 5 if ( size>2. ) { save(); translate( x, y ); rotate( positionAngle ); //rotate the coordinate system lambdaDrawEllipse( dx1, dy1, size, e*size ); restore(); //reset coordinate system } else if ( size>0. ) { drawPoint( QPointF(x, y) ); } break; case 14: { // Galaxy cluster - draw a dashed circle tempBrush = brush(); setBrush( QBrush() ); psize = 1.; if ( size > 50. ) psize *= 2.; color = pen().color().name(); save(); translate( x, y ); rotate( positionAngle ); //rotate the coordinate system QPen newPen = pen(); newPen.setStyle( Qt::DashLine ); setPen( newPen ); lambdaDrawEllipse( dx1, dy1, size, e*size ); restore(); setBrush( tempBrush ); break; } default: // Unknown object or something we don't know how to draw. Just draw an ellipse with a ?-mark color = pen().color().name(); if ( size <1. && zoom > 20*MINZOOM ) size = 3.; //force ellipse above zoomFactor 20 if ( size <1. && zoom > 5*MINZOOM ) size = 1.; //force points above zoomFactor 5 if ( size>2. ) { save(); QFont f = font(); const QString qMark = " ? "; double scaleFactor = 0.8 * size / fontMetrics().width( qMark ); f.setPointSizeF( f.pointSizeF() * scaleFactor ); setFont( f ); translate( x, y ); rotate( positionAngle ); //rotate the coordinate system lambdaDrawEllipse( dx1, dy1, size, e*size ); if ( Options::useAntialias() ) drawText( QRectF(dx1, dy1, size, e*size), Qt::AlignCenter, qMark ); else { int idx1 = int(dx1); int idy1 = int(dy1); drawText( QRect(idx1, idy1, isize, int(e*size)), Qt::AlignCenter, qMark ); } restore(); //reset coordinate system (and font?) } else if ( size>0. ) { if ( Options::useAntialias() ) drawPoint( QPointF(x, y) ); else drawPoint( QPoint( x, y ) ); } } }
void Score::print () { setPlainText("SCORE: " + QString::number(score)); setDefaultTextColor(Qt::white); setFont(QFont("times",18)); }
void Hruler::paintEvent(QPaintEvent *e) { if (m_doc->isLoading()) return; QString tx = ""; double sc = m_view->scale(); Scaling = sc; QFont ff = font(); ff.setPointSize(6); setFont(ff); QPainter p; p.begin(this); p.setClipRect(e->rect()); p.setFont(font()); drawMarks(p); if (textEditMode) { int rectX1 = textPosToLocal(Extra); int rectX2 = textPosToLocal(ItemEndPos-ItemPos-RExtra); p.eraseRect(QRect(QPoint(rectX1, 1), QPoint(rectX2, 15))); p.drawLine(rectX1, 16, rectX2, 16); p.save(); p.setRenderHints(QPainter::Antialiasing, true); if (Revers) { p.translate( textPosToLocal(0), 0); p.scale(-1, 1); p.translate( textPosToLocal(Extra) - textPosToLocal(ItemEndPos-ItemPos-RExtra), 0); p.translate(-textPosToLocal(0), 0); } for (int CurrCol = 0; CurrCol < Cols; ++CurrCol) { double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols; double Pos = (ColWidth + ColGap) * CurrCol; double EndPos = Pos + ColWidth; drawTextMarks(Pos, EndPos, p); p.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); int xPos = textPosToLocal(Pos); p.drawLine(xPos, topline, xPos, bottomline); if (CurrCol == 0) { p.drawLine(xPos, 15, (xPos+4), 15); p.drawLine(xPos, topline, (xPos+4), topline); } p.setPen(QPen(Qt::blue, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); xPos = textPosToLocal(Pos+First+Indent); QPolygon cr; cr.setPoints(3, xPos, midline, xPos+3, topline, xPos-3, topline); p.drawPolygon(cr); xPos = textPosToLocal(Pos+Indent); QPolygon cr2; cr2.setPoints(3, xPos, midline, xPos+3, bottomline, xPos-3, bottomline); p.drawPolygon(cr2); xPos = textPosToLocal(Pos+RMargin); QPolygon cr3; cr3.setPoints(3, xPos, topline, xPos, bottomline, xPos-3, midline); p.drawPolygon(cr3); if (TabValues.count() != 0) { p.setPen(QPen(Qt::black, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); for (int yg = 0; yg < signed(TabValues.count()); yg++) { xPos = textPosToLocal(Pos+TabValues[yg].tabPosition); if (Pos+TabValues[yg].tabPosition < EndPos) { switch (static_cast<int>(TabValues[yg].tabType)) { case 0: if (Revers) { p.save(); p.translate(Pos + TabValues[yg].tabPosition,0); p.scale(-1,1); p.drawLine(0, tabline, 0, bottomline); p.drawLine(0, bottomline, 8, bottomline); p.restore(); } else { p.drawLine(xPos, tabline, xPos, bottomline); p.drawLine(xPos, bottomline, xPos+8, bottomline); } break; case 1: if (Revers) { p.save(); p.translate(Pos+TabValues[yg].tabPosition,0); p.scale(-1,1); p.drawLine(0, tabline, 0, bottomline); p.drawLine(0, bottomline, -8, bottomline); p.restore(); } else { p.drawLine(xPos, tabline, xPos, bottomline); p.drawLine(xPos, bottomline, xPos-8, bottomline); } break; case 2: case 3: p.drawLine(xPos, tabline, xPos, bottomline); p.drawLine(xPos-4, bottomline, xPos+4, bottomline); p.drawLine(xPos+3, bottomline-3, xPos+2, bottomline-3); break; case 4: p.drawLine(xPos, tabline, xPos, bottomline); p.drawLine(xPos-4, bottomline, xPos+4, bottomline); break; default: break; } } } } p.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); xPos = textPosToLocal(EndPos); p.drawLine(xPos, topline, xPos, bottomline); if (CurrCol == Cols-1) { p.drawLine(xPos, bottomline, xPos-4 , bottomline); p.drawLine(xPos, topline, xPos-4, topline); } } p.restore(); } if (drawMark && !Mpressed) { drawMarker(p); } p.end(); }
void GenericCodeEditor::onDocumentFontChanged() { QFont font = mDoc->defaultFont(); setFont(font); }
void Screen::synchronize(Serializer &s) { int fontNumb = _fontNumber; s.syncAsByte(fontNumb); if (s.isLoading()) setFont(fontNumb); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // open database connection db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("/Users/jdoud/dev/brainstorm.sqlite"); if(!db.open()) { qDebug() << db.lastError(); qFatal("Failed to connect."); } // setup UI ui->setupUi(this); ui->toolBar->addWidget(ui->comboFonts); ui->toolBar->addWidget(ui->comboFontSizes); ui->toolBar->addWidget(ui->comboColors); // set text editor defaults ui->textNote->document()->setIndentWidth(20); ui->textNote->setTabStopWidth(20); ui->textNote->setTabChangesFocus(false); ui->actionIncrease_Indent->setShortcut(Qt::Key_Tab); ui->actionDecrease_Indent->setShortcut(Qt::Key_Backtab); // setup comboColors QPixmap pix(16, 16); pix.fill(Qt::white); ui->comboColors->addItem(pix, ""); pix.fill(Qt::black); ui->comboColors->addItem(pix, ""); pix.fill(Qt::red); ui->comboColors->addItem(pix, ""); pix.fill(Qt::blue); ui->comboColors->addItem(pix, ""); pix.fill(Qt::darkGreen); ui->comboColors->addItem(pix, ""); pix.fill(Qt::gray); ui->comboColors->addItem(pix, ""); // create system tray icon createActions(); createTrayIcon(); // create models categoriesModel = new QSqlTableModel(); categoriesModel->setTable("categories"); categoriesModel->setSort(1, Qt::AscendingOrder); categoriesModel->select(); ui->listCategories->setModel(categoriesModel); ui->listCategories->setModelColumn(1); notesModel = new QSqlTableModel(); notesModel->setTable("notes"); ui->listNotes->setModel(notesModel); ui->listNotes->setModelColumn(2); // set splitter size QList<int> sizes; sizes << 230 << 150; ui->splitterLists->setSizes(sizes); sizes.clear(); sizes << 230 << 600; ui->splitterNote->setSizes(sizes); // connect File menu slots connect(ui->actionNew_Category, SIGNAL(triggered()), this, SLOT(newCategory())); connect(ui->actionRename_Category, SIGNAL(triggered()), this, SLOT(renameCategory())); connect(ui->actionDelete_Category, SIGNAL(triggered()), this, SLOT(deleteCategory())); connect(ui->actionNew_Note, SIGNAL(triggered()), this, SLOT(newNote())); connect(ui->actionRename_Note, SIGNAL(triggered()), this, SLOT(renameNote())); connect(ui->actionSave_Note, SIGNAL(triggered()), this, SLOT(saveNote())); connect(ui->actionDelete_Note, SIGNAL(triggered()), this, SLOT(deleteNote())); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(quit())); // connect Edit menu slots connect(ui->actionFind_Replace, SIGNAL(triggered()), this, SLOT(findAndReplace())); // connect Format menu slots connect(ui->actionBold, SIGNAL(triggered()), this, SLOT(bold())); connect(ui->actionItalic, SIGNAL(triggered()), this, SLOT(italic())); connect(ui->actionUnderline, SIGNAL(triggered()), this, SLOT(underline())); connect(ui->actionStrikethrough, SIGNAL(triggered()), this, SLOT(strikethrough())); connect(ui->actionBullet_List, SIGNAL(triggered()), this, SLOT(bulletList())); connect(ui->actionNumber_List, SIGNAL(triggered()), this, SLOT(numberList())); connect(ui->actionIncrease_Indent, SIGNAL(triggered()), this, SLOT(increaseIndent())); connect(ui->actionDecrease_Indent, SIGNAL(triggered()), this, SLOT(decreaseIndent())); connect(ui->actionShow_Colors, SIGNAL(triggered()), this, SLOT(showColors())); connect(ui->actionShow_Fonts, SIGNAL(triggered()), this, SLOT(showFonts())); connect(ui->actionIncrease_Font, SIGNAL(triggered()), this, SLOT(increaseFont())); connect(ui->actionDecrease_Font, SIGNAL(triggered()), this, SLOT(decreaseFont())); connect(ui->actionReset_Font, SIGNAL(triggered()), this, SLOT(resetFont())); connect(ui->actionAlign_Left, SIGNAL(triggered()), this, SLOT(alignLeft())); connect(ui->actionAlign_Center, SIGNAL(triggered()), this, SLOT(alignCenter())); connect(ui->actionAlign_Right, SIGNAL(triggered()), this, SLOT(alignRight())); connect(ui->actionAlign_Justify, SIGNAL(triggered()), this, SLOT(alignJustify())); // connect View menu slots connect(ui->actionHide_Window, SIGNAL(triggered()), this, SLOT(hide())); connect(ui->actionPrevious_Category, SIGNAL(triggered()), this, SLOT(previousCategory())); connect(ui->actionNext_Category, SIGNAL(triggered()), this, SLOT(nextCategory())); connect(ui->actionPrevious_Note, SIGNAL(triggered()), this, SLOT(previousNote())); connect(ui->actionNext_Note, SIGNAL(triggered()), this, SLOT(nextNote())); // connect Help menu slots connect(ui->actionAbout_Brainstorm, SIGNAL(triggered()), this, SLOT(aboutBrainstorm())); connect(ui->actionAbout_Qt, SIGNAL(triggered()), this, SLOT(aboutQt())); // connect application slots connect(ui->textNote, SIGNAL(cursorPositionChanged()), this, SLOT(updateMenus())); connect(ui->textNote, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(updateMenus())); connect(ui->comboFonts, SIGNAL(activated(QString)), this, SLOT(setFont(QString))); connect(ui->comboFontSizes, SIGNAL(activated(QString)), this, SLOT(setFontSize(QString))); connect(ui->comboColors, SIGNAL(activated(int)), this, SLOT(setFontColor(int))); // connect category list slots connect(ui->listCategories->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteList(QModelIndex))); // connect note list slots connect(ui->listNotes->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteText(QModelIndex))); // connect text slots ui->textNote->installEventFilter((this)); // connect system tray icon connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); // initialize default data ui->listCategories->selectionModel()->setCurrentIndex(categoriesModel->index(0, 1), QItemSelectionModel::SelectCurrent); }
////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // PlayAnim / PlayAnimAsync ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "PlayAnim") == 0 || strcmp(name, "PlayAnimAsync") == 0) { stack->correctParams(1); if (DID_FAIL(playAnim(stack->pop()->getString()))) { stack->pushBool(false); } else { if (strcmp(name, "PlayAnimAsync") != 0) { script->waitFor(this); } stack->pushBool(true); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Reset ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Reset") == 0) { stack->correctParams(0); reset(); stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // IsTalking ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsTalking") == 0) { stack->correctParams(0); stack->pushBool(_state == STATE_TALKING); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // StopTalk / StopTalking ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StopTalk") == 0 || strcmp(name, "StopTalking") == 0) { stack->correctParams(0); if (_sentence) { _sentence->finish(); } if (_state == STATE_TALKING) { _state = _nextState; _nextState = STATE_READY; stack->pushBool(true); } else { stack->pushBool(false); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // ForceTalkAnim ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ForceTalkAnim") == 0) { stack->correctParams(1); const char *animName = stack->pop()->getString(); delete[] _forcedTalkAnimName; _forcedTalkAnimName = new char[strlen(animName) + 1]; strcpy(_forcedTalkAnimName, animName); _forcedTalkAnimUsed = false; stack->pushBool(true); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Talk / TalkAsync ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Talk") == 0 || strcmp(name, "TalkAsync") == 0) { stack->correctParams(5); const char *text = stack->pop()->getString(); ScValue *soundVal = stack->pop(); int duration = stack->pop()->getInt(); ScValue *valStances = stack->pop(); const char *stances = valStances->isNULL() ? nullptr : valStances->getString(); int align = 0; ScValue *val = stack->pop(); if (val->isNULL()) { align = TAL_CENTER; } else { align = val->getInt(); } align = MIN(MAX(0, align), NUM_TEXT_ALIGN - 1); const char *sound = soundVal->isNULL() ? nullptr : soundVal->getString(); talk(text, sound, duration, stances, (TTextAlign)align); if (strcmp(name, "TalkAsync") != 0) { script->waitForExclusive(this); } stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // StickToRegion ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StickToRegion") == 0) { stack->correctParams(1); AdLayer *main = ((AdGame *)_gameRef)->_scene->_mainLayer; bool regFound = false; uint32 i; ScValue *val = stack->pop(); if (val->isNULL() || !main) { _stickRegion = nullptr; regFound = true; } else if (val->isString()) { const char *regionName = val->getString(); for (i = 0; i < main->_nodes.size(); i++) { if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->getName() && scumm_stricmp(main->_nodes[i]->_region->getName(), regionName) == 0) { _stickRegion = main->_nodes[i]->_region; regFound = true; break; } } } else if (val->isNative()) { BaseScriptable *obj = val->getNative(); for (i = 0; i < main->_nodes.size(); i++) { if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region == obj) { _stickRegion = main->_nodes[i]->_region; regFound = true; break; } } } if (!regFound) { _stickRegion = nullptr; } stack->pushBool(regFound); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SetFont ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFont") == 0) { stack->correctParams(1); ScValue *val = stack->pop(); if (val->isNULL()) { setFont(nullptr); } else { setFont(val->getString()); } stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetFont ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFont") == 0) { stack->correctParams(0); if (_font && _font->getFilename()) { stack->pushString(_font->getFilename()); } else { stack->pushNULL(); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // TakeItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TakeItem") == 0) { stack->correctParams(2); if (!_inventory) { _inventory = new AdInventory(_gameRef); ((AdGame *)_gameRef)->registerInventory(_inventory); } ScValue *val = stack->pop(); if (!val->isNULL()) { const char *itemName = val->getString(); val = stack->pop(); const char *insertAfter = val->isNULL() ? nullptr : val->getString(); if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) { script->runtimeError("Cannot add item '%s' to inventory", itemName); } else { // hide associated entities ((AdGame *)_gameRef)->_scene->handleItemAssociations(itemName, false); } } else { script->runtimeError("TakeItem: item name expected"); } stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // DropItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DropItem") == 0) { stack->correctParams(1); if (!_inventory) { _inventory = new AdInventory(_gameRef); ((AdGame *)_gameRef)->registerInventory(_inventory); } ScValue *val = stack->pop(); if (!val->isNULL()) { if (DID_FAIL(_inventory->removeItem(val->getString()))) { script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); } else { // show associated entities ((AdGame *)_gameRef)->_scene->handleItemAssociations(val->getString(), true); } } else { script->runtimeError("DropItem: item name expected"); } stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetItem") == 0) { stack->correctParams(1); if (!_inventory) { _inventory = new AdInventory(_gameRef); ((AdGame *)_gameRef)->registerInventory(_inventory); } ScValue *val = stack->pop(); if (val->_type == VAL_STRING) { AdItem *item = ((AdGame *)_gameRef)->getItemByName(val->getString()); if (item) { stack->pushNative(item, true); } else { stack->pushNULL(); } } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= (int32)_inventory->_takenItems.size()) { stack->pushNULL(); } else { stack->pushNative(_inventory->_takenItems[val->getInt()], true); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // HasItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HasItem") == 0) { stack->correctParams(1); if (!_inventory) { _inventory = new AdInventory(_gameRef); ((AdGame *)_gameRef)->registerInventory(_inventory); } ScValue *val = stack->pop(); if (!val->isNULL()) { for (uint32 i = 0; i < _inventory->_takenItems.size(); i++) { if (val->getNative() == _inventory->_takenItems[i]) { stack->pushBool(true); return STATUS_OK; } else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->getName()) == 0) { stack->pushBool(true); return STATUS_OK; } } } else { script->runtimeError("HasItem: item name expected"); } stack->pushBool(false); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // CreateParticleEmitter ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateParticleEmitter") == 0) { stack->correctParams(3); bool followParent = stack->pop()->getBool(); int offsetX = stack->pop()->getInt(); int offsetY = stack->pop()->getInt(); PartEmitter *emitter = createParticleEmitter(followParent, offsetX, offsetY); if (emitter) { stack->pushNative(_partEmitter, true); } else { stack->pushNULL(); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // DeleteParticleEmitter ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteParticleEmitter") == 0) { stack->correctParams(0); if (_partEmitter) { _gameRef->unregisterObject(_partEmitter); _partEmitter = nullptr; } stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // AddAttachment ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddAttachment") == 0) { stack->correctParams(4); const char *filename = stack->pop()->getString(); bool preDisplay = stack->pop()->getBool(true); int offsetX = stack->pop()->getInt(); int offsetY = stack->pop()->getInt(); bool res; AdEntity *ent = new AdEntity(_gameRef); if (DID_FAIL(res = ent->loadFile(filename))) { delete ent; ent = nullptr; script->runtimeError("AddAttachment() failed loading entity '%s'", filename); stack->pushBool(false); } else { _gameRef->registerObject(ent); ent->_posX = offsetX; ent->_posY = offsetY; ent->_active = true; if (preDisplay) { _attachmentsPre.add(ent); } else { _attachmentsPost.add(ent); } stack->pushBool(true); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // RemoveAttachment ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveAttachment") == 0) { stack->correctParams(1); ScValue *val = stack->pop(); bool found = false; if (val->isNative()) { BaseScriptable *obj = val->getNative(); for (uint32 i = 0; i < _attachmentsPre.size(); i++) { if (_attachmentsPre[i] == obj) { found = true; _gameRef->unregisterObject(_attachmentsPre[i]); _attachmentsPre.remove_at(i); i--; } } for (uint32 i = 0; i < _attachmentsPost.size(); i++) { if (_attachmentsPost[i] == obj) { found = true; _gameRef->unregisterObject(_attachmentsPost[i]); _attachmentsPost.remove_at(i); i--; } } } else { const char *attachmentName = val->getString(); for (uint32 i = 0; i < _attachmentsPre.size(); i++) { if (_attachmentsPre[i]->getName() && scumm_stricmp(_attachmentsPre[i]->getName(), attachmentName) == 0) { found = true; _gameRef->unregisterObject(_attachmentsPre[i]); _attachmentsPre.remove_at(i); i--; } } for (uint32 i = 0; i < _attachmentsPost.size(); i++) { if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) { found = true; _gameRef->unregisterObject(_attachmentsPost[i]); _attachmentsPost.remove_at(i); i--; } } } stack->pushBool(found); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetAttachment ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetAttachment") == 0) { stack->correctParams(1); ScValue *val = stack->pop(); AdObject *ret = nullptr; if (val->isInt()) { int index = val->getInt(); int currIndex = 0; for (uint32 i = 0; i < _attachmentsPre.size(); i++) { if (currIndex == index) { ret = _attachmentsPre[i]; } currIndex++; } for (uint32 i = 0; i < _attachmentsPost.size(); i++) { if (currIndex == index) { ret = _attachmentsPost[i]; } currIndex++; } } else { const char *attachmentName = val->getString(); for (uint32 i = 0; i < _attachmentsPre.size(); i++) { if (_attachmentsPre[i]->getName() && scumm_stricmp(_attachmentsPre[i]->getName(), attachmentName) == 0) { ret = _attachmentsPre[i]; break; } } if (!ret) { for (uint32 i = 0; i < _attachmentsPost.size(); i++) { if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) { ret = _attachmentsPre[i]; break; } } } } if (ret != nullptr) { stack->pushNative(ret, true); } else { stack->pushNULL(); } return STATUS_OK; } else { return BaseObject::scCallMethod(script, stack, thisStack, name); } }
void WzMainWindow::setFontSize(float size) { QFont theFont = font(); theFont.setPixelSize(size); setFont(theFont); }
NCRDSqlTextEdit::NCRDSqlTextEdit(QWidget * parent) : QTextEdit( parent ) { setFont( QFont("Courier New",10) ); }
MainWidget::MainWidget(QWidget *parent,const char *name) :QWidget(parent,name) { gpi_scroll_mode=false; // // Read Command Options // RDCmdSwitch *cmd=new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdgpimon","\n"); delete cmd; // // Set Window Size // setMinimumWidth(sizeHint().width()); setMaximumWidth(sizeHint().width()); setMinimumHeight(sizeHint().height()); setMaximumHeight(sizeHint().height()); // // Create Fonts // QFont font("helvetica",10,QFont::Normal); font.setPixelSize(10); setFont(font); QFont list_font("helvetica",12,QFont::Normal); list_font.setPixelSize(12); QFont main_font("helvetica",12,QFont::Bold); main_font.setPixelSize(12); QFont title_font("helvetica",14,QFont::Bold); title_font.setPixelSize(14); // // Create And Set Icon // gpi_rivendell_map=new QPixmap(rivendell_xpm); setIcon(*gpi_rivendell_map); // // Load Local Configs // gpi_config=new RDConfig(); gpi_config->load(); // // Open Database // gpi_db=QSqlDatabase::addDatabase(gpi_config->mysqlDriver()); if(!gpi_db) { QMessageBox::warning(this,tr("Database Error"), tr("Can't Connect","Unable to connect to mySQL Server!")); exit(0); } gpi_db->setDatabaseName(gpi_config->mysqlDbname()); gpi_db->setUserName(gpi_config->mysqlUsername()); gpi_db->setPassword(gpi_config->mysqlPassword()); gpi_db->setHostName(gpi_config->mysqlHostname()); if(!gpi_db->open()) { QMessageBox::warning(this,tr("Can't Connect"), tr("Unable to connect to mySQL Server!")); gpi_db->removeDatabase(gpi_config->mysqlDbname()); exit(0); } new RDDbHeartbeat(gpi_config->mysqlHeartbeatInterval(),this); // // RIPC Connection // gpi_ripc=new RDRipc(gpi_config->stationName()); gpi_ripc->setIgnoreMask(true); connect(gpi_ripc,SIGNAL(userChanged()),this,SLOT(userData())); connect(gpi_ripc,SIGNAL(gpiStateChanged(int,int,bool)), this,SLOT(gpiStateChangedData(int,int,bool))); connect(gpi_ripc,SIGNAL(gpoStateChanged(int,int,bool)), this,SLOT(gpoStateChangedData(int,int,bool))); connect(gpi_ripc,SIGNAL(gpiMaskChanged(int,int,bool)), this,SLOT(gpiMaskChangedData(int,int,bool))); connect(gpi_ripc,SIGNAL(gpoMaskChanged(int,int,bool)), this,SLOT(gpoMaskChangedData(int,int,bool))); connect(gpi_ripc,SIGNAL(gpiCartChanged(int,int,int,int)), this,SLOT(gpiCartChangedData(int,int,int,int))); connect(gpi_ripc,SIGNAL(gpoCartChanged(int,int,int,int)), this,SLOT(gpoCartChangedData(int,int,int,int))); gpi_ripc->connectHost("localhost",RIPCD_TCP_PORT,gpi_config->password()); // // RDStation // gpi_station=new RDStation(gpi_config->stationName()); // // RDMatrix; // gpi_matrix=NULL; // // Type Selector // gpi_type_box=new QComboBox(this); gpi_type_box->setGeometry(80,10,120,21); gpi_type_box->insertItem(tr("GPI (Inputs)")); gpi_type_box->insertItem(tr("GPO (Outputs)")); QLabel *label=new QLabel(gpi_type_box,tr("Show:"),this); label->setGeometry(20,10,55,21); label->setFont(main_font); label->setAlignment(AlignRight|AlignVCenter); connect(gpi_type_box,SIGNAL(activated(int)), this,SLOT(matrixActivatedData(int))); // // Matrix Selector // gpi_matrix_box=new QComboBox(this); gpi_matrix_box->setGeometry(280,10,80,21); for(int i=0;i<MAX_MATRICES;i++) { gpi_matrix_box->insertItem(QString().sprintf("%d",i)); } label=new QLabel(gpi_matrix_box,tr("Matrix:"),this); label->setGeometry(220,10,55,21); label->setFont(main_font); label->setAlignment(AlignRight|AlignVCenter); connect(gpi_matrix_box,SIGNAL(activated(int)), this,SLOT(matrixActivatedData(int))); // // GPI Indicators // for(int i=0;i<GPIMON_ROWS;i++) { for(int j=0;j<GPIMON_COLS;j++) { gpi_labels[i*GPIMON_COLS+j]=new GpiLabel(this); gpi_labels[i*GPIMON_COLS+j]->setGeometry(10+64*j,40+78*i, gpi_labels[i*GPIMON_COLS+j]-> sizeHint().width(), gpi_labels[i*GPIMON_COLS+j]-> sizeHint().height()); } } // // Up Button // gpi_up_button= new RDTransportButton(RDTransportButton::Up,this); gpi_up_button->setGeometry(10,360,80,50); connect(gpi_up_button,SIGNAL(clicked()),this,SLOT(upData())); // // Down Button // gpi_down_button= new RDTransportButton(RDTransportButton::Down,this); gpi_down_button->setGeometry(100,360,80,50); connect(gpi_down_button,SIGNAL(clicked()),this,SLOT(downData())); // // Color Key // label=new QLabel(tr("Green = ON Cart"),this); label->setGeometry(200,370,300,12); label->setFont(main_font); label->setAlignment(AlignLeft|AlignVCenter); QPalette p=palette(); p.setColor(QPalette::Active,QColorGroup::Foreground,darkGreen); p.setColor(QPalette::Inactive,QColorGroup::Foreground,darkGreen); p.setColor(QPalette::Disabled,QColorGroup::Foreground,darkGreen); label->setPalette(p); label=new QLabel(tr("Red = OFF Cart"),this); label->setGeometry(200,392,300,12); label->setFont(main_font); label->setAlignment(AlignLeft|AlignVCenter); p.setColor(QPalette::Active,QColorGroup::Foreground,darkRed); p.setColor(QPalette::Inactive,QColorGroup::Foreground,darkRed); p.setColor(QPalette::Disabled,QColorGroup::Foreground,darkRed); label->setPalette(p); // // Events Log // label=new QLabel(tr("Events Log"),this); label->setFont(title_font); label->setAlignment(Qt::AlignCenter); label->setGeometry(110,423,sizeHint().width()-220,30); gpi_events_date_edit=new QDateEdit(this); gpi_events_date_edit->setGeometry(155,453,90,20); gpi_events_date_edit->setDate(QDate::currentDate()); connect(gpi_events_date_edit,SIGNAL(valueChanged(const QDate &)), this,SLOT(eventsDateChangedData(const QDate &))); gpi_events_date_label=new QLabel(gpi_events_date_edit,tr("Date")+":",this); gpi_events_date_label->setGeometry(100,453,50,20); gpi_events_date_label->setFont(main_font); gpi_events_date_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); gpi_events_state_box=new QComboBox(this); gpi_events_state_box->setGeometry(280,453,55,20); gpi_events_state_box->insertItem(tr("On")); gpi_events_state_box->insertItem(tr("Off")); gpi_events_state_box->insertItem(tr("Both")); connect(gpi_events_state_box,SIGNAL(activated(int)), this,SLOT(eventsStateChangedData(int))); gpi_events_state_label=new QLabel(gpi_events_state_box,tr("State")+":",this); gpi_events_state_label->setGeometry(225,453,50,20); gpi_events_state_label->setFont(main_font); gpi_events_state_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); gpi_events_list=new RDListView(this); gpi_events_list->setFont(main_font); gpi_events_list->setGeometry(110,480,sizeHint().width()-220,230); gpi_events_list->setItemMargin(5); gpi_events_list->setSelectionMode(QListView::NoSelection); gpi_events_list->addColumn("Time"); gpi_events_list->setColumnAlignment(0,Qt::AlignHCenter); gpi_events_list->setColumnSortType(1,RDListView::TimeSort); gpi_events_list->addColumn(tr("Line")); gpi_events_list->setColumnAlignment(1,Qt::AlignHCenter); gpi_events_list->setColumnSortType(1,RDListView::GpioSort); gpi_events_list->addColumn(tr("State")); gpi_events_list->setColumnAlignment(2,Qt::AlignHCenter); gpi_events_scroll_button=new QPushButton(tr("Scroll"),this); gpi_events_scroll_button->setGeometry(sizeHint().width()-100,510,80,50); gpi_events_scroll_button->setFont(main_font); connect(gpi_events_scroll_button,SIGNAL(clicked()), this,SLOT(eventsScrollData())); gpi_scroll_color=palette(); gpi_scroll_color.setColor(QPalette::Active,QColorGroup::ButtonText, Qt::white); gpi_scroll_color.setColor(QPalette::Active,QColorGroup::Button, Qt::blue); gpi_scroll_color.setColor(QPalette::Active,QColorGroup::Background, lightGray); gpi_scroll_color.setColor(QPalette::Inactive,QColorGroup::ButtonText, Qt::white); gpi_scroll_color.setColor(QPalette::Inactive,QColorGroup::Button, Qt::blue); gpi_scroll_color.setColor(QPalette::Inactive,QColorGroup::Background, lightGray); gpi_events_report_button=new QPushButton(tr("Report"),this); gpi_events_report_button->setGeometry(sizeHint().width()-100,570,80,50); gpi_events_report_button->setFont(main_font); connect(gpi_events_report_button,SIGNAL(clicked()), this,SLOT(eventsReportData())); // // Start Up Timer // gpi_events_startup_timer=new QTimer(this); connect(gpi_events_startup_timer,SIGNAL(timeout()),this,SLOT(startUpData())); gpi_events_startup_timer->start(GPIMON_START_UP_DELAY,true); }
KexiRecordNavigator::KexiRecordNavigator(QWidget *parent, Q3ScrollView* parentView, int leftMargin) : QWidget(parent) , d(new Private) { setAutoFillBackground(true); setFocusPolicy(Qt::NoFocus); if (parentView) setParentView(parentView); d->lyr = new QHBoxLayout(this); // const bool winStyle = style()->objectName().toLower() == "windows"; // used to fix appearance of the number field d->lyr->setContentsMargins(0, /*winStyle ? 1 :*/ 0, 0, 0); d->lyr->setSpacing(2); d->textLabel = new QLabel(this); d->lyr->addWidget(d->textLabel); setLabelText(i18n("Record:")); setFont( KexiUtils::smallFont() ); QFontMetrics fm(font()); d->nav1DigitWidth = fm.width("8"); d->navBtnFirst = createAction(KexiRecordNavigator::Actions::moveToFirstRecord()); d->navBtnPrev = createAction(KexiRecordNavigator::Actions::moveToPreviousRecord()); d->navBtnPrev->setAutoRepeat(true); d->lyr->addSpacing(2); d->navRecordNumber = new KLineEdit(this); d->lyr->addWidget(d->navRecordNumber, 0, Qt::AlignVCenter); KexiUtils::WidgetMargins margins; // margins.top = winStyle ? 1 : 0; // margins.bottom = winStyle ? 1 : 0; margins.copyToWidget(d->navRecordNumber); d->navRecordNumber->setFrame(false); if (parentView) { kDebug() << parentView->horizontalScrollBar()->height(); d->navRecordNumber->setFixedHeight( qMax(parentView->bottomMargin(), fm.height() + 2) ); } d->navRecordNumber->setAlignment(Qt::AlignRight | (/*winStyle ? Qt::AlignBottom :*/ Qt::AlignVCenter)); d->navRecordNumber->setFocusPolicy(Qt::ClickFocus); d->navRecordNumberValidator = new QIntValidator(1, INT_MAX, this); d->navRecordNumber->setValidator(d->navRecordNumberValidator); d->navRecordNumber->installEventFilter(this); d->navRecordNumber->setToolTip(i18n("Current record number")); QLabel *lbl_of = new QLabel(i18nc("\"of\" in record number information: N of M", "of"), this); lbl_of->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); lbl_of->setFixedWidth(fm.width(lbl_of->text()) + d->nav1DigitWidth); lbl_of->setAlignment(Qt::AlignCenter); d->lyr->addWidget(lbl_of, 0, Qt::AlignVCenter); d->navRecordCount = new KLineEdit(this); d->lyr->addWidget(d->navRecordCount, 0, Qt::AlignVCenter); // d->navRecordCount->setTextInteractionFlags(Qt::TextSelectableByMouse); d->navRecordCount->setFrame(false); d->navRecordCount->setReadOnly(true); QPalette navRecordCountPalette(d->navRecordCount->palette()); // navRecordCountPalette.setBrush( QPalette::Base, navRecordCountPalette.brush(QPalette::Window) ); navRecordCountPalette.setBrush( QPalette::Base, QBrush(Qt::transparent) ); d->navRecordCount->setPalette(navRecordCountPalette); if (parentView) { d->navRecordCount->setFixedHeight( qMax(parentView->bottomMargin(), fm.height() + 2) ); } d->navRecordCount->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); d->navRecordCount->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); d->navRecordCount->setFocusPolicy(Qt::NoFocus); d->navRecordCount->setToolTip(i18n("Number of records")); d->navBtnNext = createAction(KexiRecordNavigator::Actions::moveToNextRecord()); d->navBtnNext->setAutoRepeat(true); d->navBtnLast = createAction(KexiRecordNavigator::Actions::moveToLastRecord()); d->lyr->addSpacing(2); d->navBtnNew = createAction(KexiRecordNavigator::Actions::moveToNewRecord()); d->navBtnNew->setEnabled(isInsertingEnabled()); d->lyr->addSpacing(6); d->lyr->addStretch(10); connect(d->navBtnPrev, SIGNAL(clicked()), this, SLOT(slotPrevButtonClicked())); connect(d->navBtnNext, SIGNAL(clicked()), this, SLOT(slotNextButtonClicked())); connect(d->navBtnLast, SIGNAL(clicked()), this, SLOT(slotLastButtonClicked())); connect(d->navBtnFirst, SIGNAL(clicked()), this, SLOT(slotFirstButtonClicked())); connect(d->navBtnNew, SIGNAL(clicked()), this, SLOT(slotNewButtonClicked())); setRecordCount(0); setCurrentRecordNumber(0); updateGeometry(leftMargin); }
void MultiLineEdit::setCustomFont(const QFont &font) { setFont(font); updateSizeHint(); }