Example #1
0
bool KatePrinter::print (KateDocument *doc)
{
  QPrinter printer;
  readSettings(printer);

  // docname is now always there, including the right Untitled name
  printer.setDocName(doc->documentName());

  KatePrintTextSettings *kpts = new KatePrintTextSettings;
  KatePrintHeaderFooter *kphf = new KatePrintHeaderFooter;
  KatePrintLayout *kpl = new KatePrintLayout;

  QList<QWidget*> tabs;
  tabs << kpts;
  tabs << kphf;
  tabs << kpl;

  QWidget *parentWidget=doc->widget();

  if ( !parentWidget )
    parentWidget=QApplication::activeWindow();

  QScopedPointer<QPrintDialog> printDialog(KdePrint::createPrintDialog(&printer, KdePrint::SystemSelectsPages, tabs, parentWidget));

  if ( doc->activeView()->selection() ) {
    printer.setPrintRange(QPrinter::Selection);
    printDialog->setOption(QAbstractPrintDialog::PrintSelection, true);
  }

  if ( printDialog->exec() )
  {
    writeSettings(printer);

    KateRenderer renderer(doc, doc->activeKateView());
    renderer.config()->setSchema (kpl->colorScheme());
    renderer.setPrinterFriendly(true);

    QPainter paint( &printer );
    /*
     *        We work in tree cycles:
     *        1) initialize variables and retrieve print settings
     *        2) prepare data according to those settings
     *        3) draw to the printer
     */
    uint pdmWidth = printer.width();
    uint pdmHeight = printer.height();
    int y = 0;
    uint xstart = 0; // beginning point for painting lines
    uint lineCount = 0;
    uint maxWidth = pdmWidth;
    int headerWidth = pdmWidth;
    int startCol = 0;
    int endCol = 0;
    bool pageStarted = true;
    int remainder = 0; // remaining sublines from a wrapped line (for the top of a new page)

    // Text Settings Page
    bool selectionOnly = (printDialog->printRange() == QAbstractPrintDialog::Selection);
    bool useGuide = kpts->printGuide();

    bool printLineNumbers = kpts->printLineNumbers();
    uint lineNumberWidth( 0 );

    // Header/Footer Page
    QFont headerFont(kphf->font()); // used for header/footer

    bool useHeader = kphf->useHeader();
    QColor headerBgColor(kphf->headerBackground());
    QColor headerFgColor(kphf->headerForeground());
    uint headerHeight( 0 ); // further init only if needed
    QStringList headerTagList; // do
    bool headerDrawBg = false; // do

    bool useFooter = kphf->useFooter();
    QColor footerBgColor(kphf->footerBackground());
    QColor footerFgColor(kphf->footerForeground());
    uint footerHeight( 0 ); // further init only if needed
    QStringList footerTagList; // do
    bool footerDrawBg = false; // do

    // Layout Page
    renderer.config()->setSchema( kpl->colorScheme() );
    bool useBackground = kpl->useBackground();
    bool useBox = kpl->useBox();
    int boxWidth(kpl->boxWidth());
    QColor boxColor(kpl->boxColor());
    int innerMargin = useBox ? kpl->boxMargin() : 6;

    // Post initialization
    int maxHeight = (useBox ? pdmHeight-innerMargin : pdmHeight);
    uint currentPage( 1 );
    uint lastline = doc->lastLine(); // necessary to print selection only
    uint firstline( 0 );
    const int fontHeight = renderer.fontHeight();
    KTextEditor::Range selectionRange;

    /*
    *        Now on for preparations...
    *        during preparations, variable names starting with a "_" means
    *        those variables are local to the enclosing block.
    */
    {
      if ( selectionOnly )
      {
        // set a line range from the first selected line to the last
        selectionRange = doc->activeView()->selectionRange();
        firstline = selectionRange.start().line();
        lastline = selectionRange.end().line();
        lineCount = firstline;
      }

      if ( printLineNumbers )
      {
        // figure out the horiizontal space required
        QString s( QString("%1 ").arg( doc->lines() ) );
        s.fill('5', -1); // some non-fixed fonts haven't equally wide numbers
        // FIXME calculate which is actually the widest...
        lineNumberWidth = renderer.currentFontMetrics().width( s );
        // a small space between the line numbers and the text
        int _adj = renderer.currentFontMetrics().width( "5" );
        // adjust available width and set horizontal start point for data
        maxWidth -= (lineNumberWidth + _adj);
        xstart += lineNumberWidth + _adj;
      }

      if ( useHeader || useFooter )
      {
        // Set up a tag map
        // This retrieves all tags, ued or not, but
        // none of theese operations should be expensive,
        // and searcing each tag in the format strings is avoided.
        QDateTime dt = QDateTime::currentDateTime();
        QMap<QString,QString> tags;

        KUser u (KUser::UseRealUserID);
        tags["u"] = u.loginName();

        tags["d"] = KGlobal::locale()->formatDateTime(dt, KLocale::ShortDate);
        tags["D"] =  KGlobal::locale()->formatDateTime(dt, KLocale::LongDate);
        tags["h"] =  KGlobal::locale()->formatTime(dt.time(), false);
        tags["y"] =  KGlobal::locale()->formatDate(dt.date(), KLocale::ShortDate);
        tags["Y"] =  KGlobal::locale()->formatDate(dt.date(), KLocale::LongDate);
        tags["f"] =  doc->url().fileName();
        tags["U"] =  doc->url().prettyUrl();
        if ( selectionOnly )
        {
          QString s( i18n("(Selection of) ") );
          tags["f"].prepend( s );
          tags["U"].prepend( s );
        }

        QRegExp reTags( "%([dDfUhuyY])" ); // TODO tjeck for "%%<TAG>"

        if (useHeader)
        {
          headerDrawBg = kphf->useHeaderBackground();
          headerHeight = QFontMetrics( headerFont ).height();
          if ( useBox || headerDrawBg )
            headerHeight += innerMargin * 2;
          else
            headerHeight += 1 + QFontMetrics( headerFont ).leading();

          headerTagList = kphf->headerFormat();
          QMutableStringListIterator it(headerTagList);
          while ( it.hasNext() ) {
            QString tag = it.next();
            int pos = reTags.indexIn( tag );
            QString rep;
            while ( pos > -1 )
            {
              rep = tags[reTags.cap( 1 )];
              tag.replace( (uint)pos, 2, rep );
              pos += rep.length();
              pos = reTags.indexIn( tag, pos );
            }
            it.setValue( tag );
          }

          if (!headerBgColor.isValid())
            headerBgColor = Qt::lightGray;
          if (!headerFgColor.isValid())
            headerFgColor = Qt::black;
        }

        if (useFooter)
        {
          footerDrawBg = kphf->useFooterBackground();
          footerHeight = QFontMetrics( headerFont ).height();
          if ( useBox || footerDrawBg )
            footerHeight += 2*innerMargin;
          else
            footerHeight += 1; // line only

          footerTagList = kphf->footerFormat();
          QMutableStringListIterator it(footerTagList);
          while ( it.hasNext() ) {
            QString tag = it.next();
            int pos = reTags.indexIn( tag );
            QString rep;
            while ( pos > -1 )
            {
              rep = tags[reTags.cap( 1 )];
              tag.replace( (uint)pos, 2, rep );
              pos += rep.length();
              pos = reTags.indexIn( tag, pos );
            }
            it.setValue( tag );
          }

          if (!footerBgColor.isValid())
            footerBgColor = Qt::lightGray;
          if (!footerFgColor.isValid())
            footerFgColor = Qt::black;
          // adjust maxheight, so we can know when/where to print footer
          maxHeight -= footerHeight;
        }
      } // if ( useHeader || useFooter )

      if ( useBackground )
      {
        if ( ! useBox )
        {
          xstart += innerMargin;
          maxWidth -= innerMargin * 2;
        }
      }

      if ( useBox )
      {
        if (!boxColor.isValid())
          boxColor = Qt::black;
        if (boxWidth < 1) // shouldn't be pssible no more!
          boxWidth = 1;
        // set maxwidth to something sensible
        maxWidth -= ( ( boxWidth + innerMargin )  * 2 );
        xstart += boxWidth + innerMargin;
        // maxheight too..
        maxHeight -= boxWidth;
      }
      else
        boxWidth = 0;

      // now that we know the vertical amount of space needed,
      // it is possible to calculate the total number of pages
      // if needed, that is if any header/footer tag contains "%P".
      if ( !headerTagList.filter("%P").isEmpty() || !footerTagList.filter("%P").isEmpty() )
      {
        kDebug(13020)<<"'%P' found! calculating number of pages...";
        int pageHeight = maxHeight;
        if ( useHeader )
          pageHeight -= ( headerHeight + innerMargin );
        if ( useFooter )
          pageHeight -= innerMargin;
        const int linesPerPage = pageHeight / fontHeight;
//         kDebug() << "Lines per page:" << linesPerPage;
        
        // calculate total layouted lines in the document
        int totalLines = 0;
        // TODO: right now ignores selection printing
        for (int i = firstline; i <= lastline; ++i) {
          KateLineLayoutPtr rangeptr(new KateLineLayout(doc));
          rangeptr->setLine(i);
          renderer.layoutLine(rangeptr, (int)maxWidth, false);
          totalLines += rangeptr->viewLineCount();
        }
        int totalPages = (totalLines / linesPerPage)
                      + ((totalLines % linesPerPage) > 0 ? 1 : 0);
//         kDebug() << "_______ pages:" << (totalLines / linesPerPage);
//         kDebug() << "________ rest:" << (totalLines % linesPerPage);

        // TODO: add space for guide if required
//         if ( useGuide )
//           _lt += (guideHeight + (fontHeight /2)) / fontHeight;

        // substitute both tag lists
        QString re("%P");
        QStringList::Iterator it;
        for ( it=headerTagList.begin(); it!=headerTagList.end(); ++it )
          (*it).replace( re, QString( "%1" ).arg( totalPages ) );
        for ( it=footerTagList.begin(); it!=footerTagList.end(); ++it )
          (*it).replace( re, QString( "%1" ).arg( totalPages ) );
      }
    } // end prepare block

     /*
        On to draw something :-)
     */
    while (  lineCount <= lastline  )
    {
      startCol = 0;
      endCol = 0;

      if ( y + fontHeight > maxHeight )
      {
        kDebug(13020)<<"Starting new page,"<<lineCount<<"lines up to now.";
        printer.newPage();
        paint.resetTransform();
        currentPage++;
        pageStarted = true;
        y=0;
      }

      if ( pageStarted )
      {
        if ( useHeader )
        {
          paint.setPen(headerFgColor);
          paint.setFont(headerFont);
          if ( headerDrawBg )
            paint.fillRect(0, 0, headerWidth, headerHeight, headerBgColor);
          if (headerTagList.count() == 3)
          {
            int valign = ( (useBox||headerDrawBg||useBackground) ?
            Qt::AlignVCenter : Qt::AlignTop );
            int align = valign|Qt::AlignLeft;
            int marg = ( useBox || headerDrawBg ) ? innerMargin : 0;
            if ( useBox ) marg += boxWidth;
            QString s;
            for (int i=0; i<3; i++)
            {
              s = headerTagList[i];
              if (s.indexOf("%p") != -1) s.replace("%p", QString::number(currentPage));
              paint.drawText(marg, 0, headerWidth-(marg*2), headerHeight, align, s);
              align = valign|(i == 0 ? Qt::AlignHCenter : Qt::AlignRight);
            }
          }
          if ( ! ( headerDrawBg || useBox || useBackground ) ) // draw a 1 px (!?) line to separate header from contents
          {
            paint.drawLine( 0, headerHeight-1, headerWidth, headerHeight-1 );
            //y += 1; now included in headerHeight
          }
          y += headerHeight + innerMargin;
        }

        if ( useFooter )
        {
          paint.setPen(footerFgColor);
          if ( ! ( footerDrawBg || useBox || useBackground ) ) // draw a 1 px (!?) line to separate footer from contents
            paint.drawLine( 0, maxHeight + innerMargin - 1, headerWidth, maxHeight + innerMargin - 1 );
          if ( footerDrawBg )
            paint.fillRect(0, maxHeight+innerMargin+boxWidth, headerWidth, footerHeight, footerBgColor);
          if (footerTagList.count() == 3)
          {
            int align = Qt::AlignVCenter|Qt::AlignLeft;
            int marg = ( useBox || footerDrawBg ) ? innerMargin : 0;
            if ( useBox ) marg += boxWidth;
            QString s;
            for (int i=0; i<3; i++)
            {
              s = footerTagList[i];
              if (s.indexOf("%p") != -1) s.replace("%p", QString::number(currentPage));
              paint.drawText(marg, maxHeight+innerMargin, headerWidth-(marg*2), footerHeight, align, s);
              align = Qt::AlignVCenter|(i == 0 ? Qt::AlignHCenter : Qt::AlignRight);
            }
          }
        } // done footer

        if ( useBackground )
        {
          // If we have a box, or the header/footer has backgrounds, we want to paint
          // to the border of those. Otherwise just the contents area.
          int _y = y, _h = maxHeight - y;
          if ( useBox )
          {
            _y -= innerMargin;
            _h += 2 * innerMargin;
          }
          else
          {
            if ( headerDrawBg )
            {
              _y -= innerMargin;
              _h += innerMargin;
            }
            if ( footerDrawBg )
            {
              _h += innerMargin;
            }
          }
          paint.fillRect( 0, _y, pdmWidth, _h, renderer.config()->backgroundColor());
        }

        if ( useBox )
        {
          paint.setPen(QPen(boxColor, boxWidth));
          paint.drawRect(0, 0, pdmWidth, pdmHeight);
          if (useHeader)
            paint.drawLine(0, headerHeight, headerWidth, headerHeight);
          else
            y += innerMargin;

          if ( useFooter ) // drawline is not trustable, grr.
            paint.fillRect( 0, maxHeight+innerMargin, headerWidth, boxWidth, boxColor );
        }

        if ( useGuide && currentPage == 1 )
        {  // FIXME - this may span more pages...
          // draw a box unless we have boxes, in which case we end with a box line
          int _ystart = y;
          QString _hlName = doc->highlight()->name();

          QList<KateExtendedAttribute::Ptr> _attributes; // list of highlight attributes for the legend
          doc->highlight()->getKateExtendedAttributeList(kpl->colorScheme(), _attributes);

          KateAttributeList _defaultAttributes;
          KateHlManager::self()->getDefaults ( renderer.config()->schema(), _defaultAttributes );

          QColor _defaultPen = _defaultAttributes.at(0)->foreground().color();
          paint.setPen(_defaultPen);

          int _marg = 0;
          if ( useBox )
            _marg += (2*boxWidth) + (2*innerMargin);
          else
          {
            if ( useBackground )
              _marg += 2*innerMargin;
            _marg += 1;
            y += 1 + innerMargin;
          }

          // draw a title string
          QFont _titleFont = renderer.config()->font();
          _titleFont.setBold(true);
          paint.setFont( _titleFont );
          QRect _r;
          paint.drawText( QRect(_marg, y, pdmWidth-(2*_marg), maxHeight - y),
            Qt::AlignTop|Qt::AlignHCenter,
            i18n("Typographical Conventions for %1", _hlName ), &_r );
          int _w = pdmWidth - (_marg*2) - (innerMargin*2);
          int _x = _marg + innerMargin;
          y += _r.height() + innerMargin;
          paint.drawLine( _x, y, _x + _w, y );
          y += 1 + innerMargin;

          int _widest( 0 );
          foreach (const KateExtendedAttribute::Ptr &attribute, _attributes)
            _widest = qMax(QFontMetrics(attribute->font()).width(attribute->name().section(':',1,1)), _widest);

          int _guideCols = _w/( _widest + innerMargin );

          // draw attrib names using their styles
          int _cw = _w/_guideCols;
          int _i(0);

          _titleFont.setUnderline(true);
          QString _currentHlName;
          foreach (const KateExtendedAttribute::Ptr &attribute, _attributes)
          {
            QString _hl = attribute->name().section(':',0,0);
            QString _name = attribute->name().section(':',1,1);
            if ( _hl != _hlName && _hl != _currentHlName ) {
              _currentHlName = _hl;
              if ( _i%_guideCols )
                y += fontHeight;
              y += innerMargin;
              paint.setFont(_titleFont);
              paint.setPen(_defaultPen);
              paint.drawText( _x, y, _w, fontHeight, Qt::AlignTop, _hl + ' ' + i18n("text") );
              y += fontHeight;
              _i = 0;
            }

            KTextEditor::Attribute _attr =  *_defaultAttributes[attribute->defaultStyleIndex()];
            _attr += *attribute;
            paint.setPen( _attr.foreground().color() );
            paint.setFont( _attr.font() );

            if (_attr.hasProperty(QTextFormat::BackgroundBrush) ) {
              QRect _rect = QFontMetrics(_attr.font()).boundingRect(_name);
              _rect.moveTo(_x + ((_i%_guideCols)*_cw), y);
               paint.fillRect(_rect, _attr.background() );
            }

            paint.drawText(( _x + ((_i%_guideCols)*_cw)), y, _cw, fontHeight, Qt::AlignTop, _name );

            _i++;
            if ( _i && ! ( _i%_guideCols ) )
              y += fontHeight;
          }

          if ( _i%_guideCols )
            y += fontHeight;// last row not full

          // draw a box around the legend
          paint.setPen ( _defaultPen );
          if ( useBox )
            paint.fillRect( 0, y+innerMargin, headerWidth, boxWidth, boxColor );
          else
          {
            _marg -=1;
            paint.drawRect( _marg, _ystart, pdmWidth-(2*_marg), y-_ystart+innerMargin );
          }

          y += ( useBox ? boxWidth : 1 ) + (innerMargin*2);
        } // useGuide

        paint.translate(xstart,y);
        pageStarted = false;
      } // pageStarted; move on to contents:)
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    int maxblock = 250;
    automation = new Automation(this);
    ip_config = new configure(this);
    readSettings();

    connect(ui->sendBtn, SIGNAL(clicked()),this, SLOT(sendMail()));
    connect(ui->browseBtn, SIGNAL(clicked()), this, SLOT(browse()));


    connect(ip_config,SIGNAL(accepted()),this,SLOT(process_config_dialog()));
    ad_ch.clear();
    ad_ch.append(ui->comboBox->currentIndex()+1);
    eas_ch.clear();
    eas_ch.append(1);
    eas_ch.append(2);
    eas_ch.append(3);
    eas_ch.append(4);
    eas_ch.append(5);
    eas_ch.append(6);
    eas_ch.append(7);
    id_ch.clear();
    id_ch.append(1);
    id_ch.append(2);
    id_ch.append(3);
    id_ch.append(4);
    id_ch.append(5);
    id_ch.append(6);
    id_ch.append(7);
    ui->mux_log_display->ensureCursorVisible();
    ui->mux_log_display->moveCursor(QTextCursor::End);
    ui->mux_log_display->verticalScrollBar()->setValue( ui->mux_log_display->verticalScrollBar()->maximum() );

    ui->mux_log_display_2->ensureCursorVisible();
    ui->mux_log_display_2->moveCursor(QTextCursor::End);
    ui->mux_log_display_2->verticalScrollBar()->setValue( ui->mux_log_display_2->verticalScrollBar()->maximum() );

    ui->event_log_display->ensureCursorVisible();
    ui->event_log_display->moveCursor(QTextCursor::End);
    ui->event_log_display->verticalScrollBar()->setValue( ui->event_log_display->verticalScrollBar()->maximum() );

    ui->encoder_display->ensureCursorVisible();
    ui->encoder_display->moveCursor(QTextCursor::End);
    ui->encoder_display->verticalScrollBar()->setValue( ui->encoder_display->verticalScrollBar()->maximum() );
    connect(automation,SIGNAL(encoder_display(QString)),ui->encoder_display,SLOT(insertPlainText(QString)));


    ui->eas_detect->ensureCursorVisible();
    ui->eas_detect->moveCursor(QTextCursor::End);
    ui->eas_detect->verticalScrollBar()->setValue( ui->eas_detect->verticalScrollBar()->maximum() );
    connect(automation,SIGNAL(eas_status(QString)),ui->stream_status_display,SLOT(insertPlainText(QString)));

    ui->ingest_display->ensureCursorVisible();
    ui->ingest_display->moveCursor(QTextCursor::End);
    ui->ingest_display->verticalScrollBar()->setValue( ui->ingest_display->verticalScrollBar()->maximum() );
    connect(automation,SIGNAL(ingest_disp(QString)),ui->ingest_display,SLOT(insertPlainText(QString)));

    ui->stream_status_display->ensureCursorVisible();
    ui->stream_status_display->moveCursor(QTextCursor::End);
    ui->stream_status_display->verticalScrollBar()->setValue( ui->stream_status_display->verticalScrollBar()->maximum() );

    QTextDocument * doc = ui->mux_log_display->document();
    doc->setMaximumBlockCount(maxblock);
    connect(automation,SIGNAL(mux_eas_log(QString)),ui->mux_log_display,SLOT( insertPlainText(QString) ) );
    connect(automation,SIGNAL(mux_log(QString)),ui->mux_log_display_2,SLOT( insertPlainText(QString) ) );
    connect(automation,SIGNAL(event_log_output(QString)),ui->event_log_display,SLOT(insertPlainText(QString)));
    connect(automation,SIGNAL(stream_status(QString)),ui->stream_status_display,SLOT(insertPlainText(QString)));
    connect(automation,SIGNAL(ingest_finished()),this,SLOT(ingest_finished()));
    connect(automation,SIGNAL(show_schedule(QList<QString>)),this,SLOT(show_schedule(QList<QString>)));
    automation->restart_eas_engine();
    ///automation->restart_mux_control();
}
Example #3
0
BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf ):QVLCFrame( _p_intf )
{
    setWindowFlags( Qt::Tool );
    setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) );
    setWindowTitle( qtr( "Edit Bookmarks" ) );
    setWindowRole( "vlc-bookmarks" );

    QGridLayout *layout = new QGridLayout( this );

    QPushButton *addButton = new QPushButton( qtr( "Create" ) );
    addButton->setToolTip( qtr( "Create a new bookmark" ) );
    QPushButton *delButton = new QPushButton( qtr( "Delete" ) );
    delButton->setToolTip( qtr( "Delete the selected item" ) );
    QPushButton *clearButton = new QPushButton( qtr( "Clear" ) );
    clearButton->setToolTip( qtr( "Delete all the bookmarks" ) );
#if 0
    QPushButton *extractButton = new QPushButton( qtr( "Extract" ) );
    extractButton->setToolTip( qtr() );
#endif
    QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );

    bookmarksList = new QTreeWidget( this );
    bookmarksList->setRootIsDecorated( false );
    bookmarksList->setAlternatingRowColors( true );
    bookmarksList->setSelectionMode( QAbstractItemView::ExtendedSelection );
    bookmarksList->setSelectionBehavior( QAbstractItemView::SelectRows );
    bookmarksList->setEditTriggers( QAbstractItemView::SelectedClicked );
    bookmarksList->setColumnCount( 3 );
    bookmarksList->resize( sizeHint() );

    QStringList headerLabels;
    headerLabels << qtr( "Description" );
    headerLabels << qtr( "Bytes" );
    headerLabels << qtr( "Time" );
    bookmarksList->setHeaderLabels( headerLabels );


    layout->addWidget( addButton, 0, 0 );
    layout->addWidget( delButton, 1, 0 );
    layout->addWidget( clearButton, 2, 0 );
    layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ), 4, 0 );
#if 0
    layout->addWidget( extractButton, 5, 0 );
#endif
    layout->addWidget( bookmarksList, 0, 1, 6, 2);
    layout->setColumnStretch( 1, 1 );
    layout->addWidget( closeButton, 7, 2 );

    CONNECT( THEMIM->getIM(), bookmarksChanged(),
             this, update() );

    CONNECT( bookmarksList, activated( QModelIndex ), this,
             activateItem( QModelIndex ) );
    CONNECT( bookmarksList, itemChanged( QTreeWidgetItem*, int ),
             this, edit( QTreeWidgetItem*, int ) );

    BUTTONACT( addButton, add() );
    BUTTONACT( delButton, del() );
    BUTTONACT( clearButton, clear() );
#if 0
    BUTTONACT( extractButton, extract() );
#endif
    BUTTONACT( closeButton, close() );

    readSettings( "Bookmarks", QSize( 435, 280 ) );
    updateGeometry();
}
GalleryWindow::GalleryWindow(Interface* interface, QWidget *parent, Gallery* pGallery)
    : KDialog(parent),
      m_interface(interface),
      mpGallery(pGallery),
      d(new Private(this))
{
    setWindowTitle( i18n("Gallery Export") );
    setButtons( KDialog::Close | KDialog::User1 | KDialog::Help);
    setModal(false);

    // About data.
    m_about = new KPAboutData(ki18n("Gallery Export"),
                              0,
                              KAboutData::License_GPL,
                              ki18n("A Kipi plugin to export image collections to a remote Gallery server."),
                              ki18n("(c) 2003-2005, Renchi Raju\n"
                                    "(c) 2006-2007, Colin Guthrie\n"
                                    "(c) 2006-2009, Gilles Caulier\n"
                                    "(c) 2008, Andrea Diamantini\n"));

    m_about->addAuthor(ki18n("Renchi Raju"), ki18n("Author"),
                       "renchi dot raju at gmail dot com");

    m_about->addAuthor(ki18n("Colin Guthrie"), ki18n("Maintainer"),
                       "kde at colin dot guthr dot ie");

    m_about->addAuthor(ki18n("Andrea Diamantini"), ki18n("Developer"),
                       "adjam7 at gmail dot com");

    m_about->addAuthor(ki18n("Gilles Caulier"), ki18n("Developer"),
                       "caulier dot gilles at gmail dot com");

    // help button

    disconnect(this, SIGNAL(helpClicked()),
               this, SLOT(slotHelp()));

    KHelpMenu *helpMenu = new KHelpMenu(this, m_about, false);
    helpMenu->menu()->removeAction(helpMenu->menu()->actions().first());
    QAction *handbook   = new QAction(i18n("Handbook"), this);
    connect(handbook, SIGNAL(triggered(bool)),
            this, SLOT(slotHelp()));
    helpMenu->menu()->insertAction(helpMenu->menu()->actions().first(), handbook);
    button(Help)->setMenu(helpMenu->menu());

    // User1 Button : to conf gallery settings
    KPushButton *confButton = button( User1 );
    confButton->setText( i18n("Settings") );
    confButton->setIcon( KIcon("configure") );
    connect(confButton, SIGNAL(clicked()),
            this, SLOT(slotSettings()) );

    // we need to let m_talker work..
    m_talker = new GalleryTalker(d->widget);

    // setting progressDlg and its numeric hints
    m_progressDlg = new QProgressDialog(this);
    m_progressDlg->setModal(true);
    m_progressDlg->setAutoReset(true);
    m_progressDlg->setAutoClose(true);
    m_uploadCount = 0;
    m_uploadTotal = 0;
    mpUploadList  = new QStringList;

    // connect functions
    connectSignals();

    // read Settings
    readSettings();

    slotDoLogin();
}
FramePlaybackWindow::FramePlaybackWindow(const QVector<CANFrame> *frames, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::FramePlaybackWindow)
{
    ui->setupUi(this);
    setWindowFlags(Qt::Window);

    int numBuses = CANConManager::getInstance()->getNumBuses();
    for (int n = 0; n < numBuses; n++) ui->comboCANBus->addItem(QString::number(n));
    ui->comboCANBus->addItem(tr("All"));
    ui->comboCANBus->addItem(tr("From File"));
    ui->comboCANBus->setCurrentIndex(0);

    playbackObject.initialize();
    playbackObject.setNumBuses(numBuses);

    readSettings();

    modelFrames = frames;

    currentSeqItem = NULL;
    currentSeqNum = -1;
    currentPosition = 0;
    forward = true;
    isPlaying = false;

    updateFrameLabel();

    connect(ui->btnStepBack, &QAbstractButton::clicked, this, &FramePlaybackWindow::btnBackOneClick);
    connect(ui->btnPause, &QAbstractButton::clicked, this, &FramePlaybackWindow::btnPauseClick);
    connect(ui->btnPlayReverse, &QAbstractButton::clicked, this, &FramePlaybackWindow::btnReverseClick);
    connect(ui->btnStop, &QAbstractButton::clicked, this, &FramePlaybackWindow::btnStopClick);
    connect(ui->btnPlay, &QAbstractButton::clicked, this, &FramePlaybackWindow::btnPlayClick);
    connect(ui->btnStepForward, &QAbstractButton::clicked, this, &FramePlaybackWindow::btnFwdOneClick);
    connect(ui->btnSelectAll, &QAbstractButton::clicked, this, &FramePlaybackWindow::btnSelectAllClick);
    connect(ui->btnSelectNone, &QAbstractButton::clicked, this, &FramePlaybackWindow::btnSelectNoneClick);
    connect(ui->btnDelete, &QAbstractButton::clicked, this, &FramePlaybackWindow::btnDeleteCurrSeq);
    connect(ui->spinPlaySpeed, SIGNAL(valueChanged(int)), this, SLOT(changePlaybackSpeed(int)));
    connect(ui->spinBurstSpeed, SIGNAL(valueChanged(int)), this, SLOT(changeBurstRate(int)));
    //connect(ui->cbLoop, SIGNAL(clicked(bool)), this, SLOT(changeLooping(bool)));
    connect(ui->comboCANBus, SIGNAL(currentIndexChanged(int)), this, SLOT(changeSendingBus(int)));
    connect(ui->listID, &QListWidget::itemChanged, this, &FramePlaybackWindow::changeIDFiltering);
    connect(ui->btnLoadFile, &QAbstractButton::clicked, this, &FramePlaybackWindow::btnLoadFile);
    connect(ui->btnLoadLive, &QAbstractButton::clicked, this, &FramePlaybackWindow::btnLoadLive);
    connect(ui->tblSequence, &QTableWidget::cellPressed, this, &FramePlaybackWindow::seqTableCellClicked);
    connect(ui->tblSequence, &QTableWidget::cellChanged, this, &FramePlaybackWindow::seqTableCellChanged);
    connect(ui->btnLoadFilters, &QAbstractButton::clicked, this, &FramePlaybackWindow::loadFilters);
    connect(ui->btnSaveFilters, &QAbstractButton::clicked, this, &FramePlaybackWindow::saveFilters);
    connect(ui->cbOriginalTiming, &QCheckBox::toggled, this, &FramePlaybackWindow::useOrigTimingClicked);

    connect(&playbackObject, &FramePlaybackObject::EndOfFrameCache, this, &FramePlaybackWindow::EndOfFrameCache);
    connect(&playbackObject, &FramePlaybackObject::statusUpdate, this, &FramePlaybackWindow::getStatusUpdate);

    ui->listID->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->listID, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuFilters(QPoint)));

    playbackObject.setPlaybackInterval(ui->spinPlaySpeed->value());

    QStringList headers;
    headers << "Source" << "Loops";
    ui->tblSequence->setColumnCount(2);
    ui->tblSequence->setColumnWidth(0, 260);
    ui->tblSequence->setColumnWidth(1, 80);
    ui->tblSequence->setHorizontalHeaderLabels(headers);
}
Example #6
0
KColorDialog::KColorDialog( TQWidget *parent, const char *name, bool modal )
  :KDialogBase( parent, name, modal, i18n("Select Color"),
		modal ? Ok|Cancel : Close,
		Ok, true )
{
  d = new KColorDialogPrivate;
  d->bRecursion = true;
  d->bColorPicking = false;
#ifdef Q_WS_X11
  d->oldfilter = 0;
#endif
  d->cbDefaultColor = 0L;
  connect( this, TQT_SIGNAL(okClicked(void)),this,TQT_SLOT(slotWriteSettings(void)));
  connect( this, TQT_SIGNAL(closeClicked(void)),this,TQT_SLOT(slotWriteSettings(void)));

  TQLabel *label;

  //
  // Create the top level page and its layout
  //
  TQWidget *page = new TQWidget( this );
  setMainWidget( page );

  TQGridLayout *tl_layout = new TQGridLayout( page, 3, 3, 0, spacingHint() );
  d->tl_layout = tl_layout;
  tl_layout->addColSpacing( 1, spacingHint() * 2 );

  //
  // the more complicated part: the left side
  // add a V-box
  //
  TQVBoxLayout *l_left = new TQVBoxLayout();
  tl_layout->addLayout(l_left, 0, 0);

  //
  // add a H-Box for the XY-Selector and a grid for the
  // entry fields
  //
  TQHBoxLayout *l_ltop = new TQHBoxLayout();
  l_left->addLayout(l_ltop);

  // a little space between
  l_left->addSpacing(10);

  TQGridLayout *l_lbot = new TQGridLayout(3, 6);
  l_left->addLayout(TQT_TQLAYOUT(l_lbot));

  //
  // the palette and value selector go into the H-box
  //
  d->hsSelector = new KHSSelector( page );
  d->hsSelector->setMinimumSize(140, 70);
  l_ltop->addWidget(d->hsSelector, 8);
  connect( d->hsSelector, TQT_SIGNAL( valueChanged( int, int ) ),
	   TQT_SLOT( slotHSChanged( int, int ) ) );

  d->valuePal = new KValueSelector( page );
  d->valuePal->setMinimumSize(26, 70);
  l_ltop->addWidget(d->valuePal, 1);
  connect( d->valuePal, TQT_SIGNAL( valueChanged( int ) ),
	   TQT_SLOT( slotVChanged( int ) ) );


  //
  // add the HSV fields
  //
  label = new TQLabel( i18n("H:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget(label, 0, 2);
  d->hedit = new KColorSpinBox( 0, 359, 1, page );
  d->hedit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->hedit) ) );
  l_lbot->addWidget(d->hedit, 0, 3);
  connect( d->hedit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotHSVChanged() ) );

  label = new TQLabel( i18n("S:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget(label, 1, 2);
  d->sedit = new KColorSpinBox( 0, 255, 1, page );
  d->sedit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->sedit) ) );
  l_lbot->addWidget(d->sedit, 1, 3);
  connect( d->sedit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotHSVChanged() ) );

  label = new TQLabel( i18n("V:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget(label, 2, 2);
  d->vedit = new KColorSpinBox( 0, 255, 1, page );
  d->vedit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->vedit) ) );
  l_lbot->addWidget(d->vedit, 2, 3);
  connect( d->vedit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotHSVChanged() ) );

  //
  // add the RGB fields
  //
  label = new TQLabel( i18n("R:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget(label, 0, 4);
  d->redit = new KColorSpinBox( 0, 255, 1, page );
  d->redit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->redit) ) );
  l_lbot->addWidget(d->redit, 0, 5);
  connect( d->redit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotRGBChanged() ) );

  label = new TQLabel( i18n("G:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget( label, 1, 4);
  d->gedit = new KColorSpinBox( 0, 255,1, page );
  d->gedit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->gedit) ) );
  l_lbot->addWidget(d->gedit, 1, 5);
  connect( d->gedit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotRGBChanged() ) );

  label = new TQLabel( i18n("B:"), page );
  label->setAlignment(AlignRight | AlignVCenter);
  l_lbot->addWidget(label, 2, 4);
  d->bedit = new KColorSpinBox( 0, 255, 1, page );
  d->bedit->setValidator( new TQIntValidator( TQT_TQOBJECT(d->bedit) ) );
  l_lbot->addWidget(d->bedit, 2, 5);
  connect( d->bedit, TQT_SIGNAL( valueChanged(int) ),
  	TQT_SLOT( slotRGBChanged() ) );

  //
  // the entry fields should be wide enough to hold 8888888
  //
  int w = d->hedit->fontMetrics().width("8888888");
  d->hedit->setFixedWidth(w);
  d->sedit->setFixedWidth(w);
  d->vedit->setFixedWidth(w);

  d->redit->setFixedWidth(w);
  d->gedit->setFixedWidth(w);
  d->bedit->setFixedWidth(w);

  //
  // add a layout for the right side
  //
  d->l_right = new TQVBoxLayout;
  tl_layout->addLayout(d->l_right, 0, 2);

  //
  // Add the palette table
  //
  d->table = new KPaletteTable( page );
  d->l_right->addWidget(d->table, 10);

  connect( d->table, TQT_SIGNAL( colorSelected( const TQColor &, const TQString & ) ),
	   TQT_SLOT( slotColorSelected( const TQColor &, const TQString & ) ) );

  connect(
    d->table,
    TQT_SIGNAL( colorDoubleClicked( const TQColor &, const TQString & ) ),
    TQT_SLOT( slotColorDoubleClicked( const TQColor &, const TQString & ) )
  );
  // Store the default value for saving time.
  d->originalPalette = d->table->palette();

  //
  // a little space between
  //
  d->l_right->addSpacing(10);

  TQHBoxLayout *l_hbox = new TQHBoxLayout( d->l_right );

  //
  // The add to custom colors button
  //
  TQPushButton *button = new TQPushButton( page );
  button->setText(i18n("&Add to Custom Colors"));
  l_hbox->addWidget(button, 0, AlignLeft);
  connect( button, TQT_SIGNAL( clicked()), TQT_SLOT( slotAddToCustomColors()));

  //
  // The color picker button
  //
  button = new TQPushButton( page );
  button->setPixmap( BarIcon("colorpicker"));
  l_hbox->addWidget(button, 0, AlignHCenter );
  connect( button, TQT_SIGNAL( clicked()), TQT_SLOT( slotColorPicker()));

  //
  // a little space between
  //
  d->l_right->addSpacing(10);

  //
  // and now the entry fields and the patch (=colored box)
  //
  TQGridLayout *l_grid = new TQGridLayout( d->l_right, 2, 3);

  l_grid->setColStretch(2, 1);

  label = new TQLabel( page );
  label->setText(i18n("Name:"));
  l_grid->addWidget(TQT_TQWIDGET(label), 0, 1, Qt::AlignLeft);

  d->colorName = new TQLabel( page );
  l_grid->addWidget(TQT_TQWIDGET(d->colorName), 0, 2, Qt::AlignLeft);

  label = new TQLabel( page );
  label->setText(i18n("HTML:"));
  l_grid->addWidget(TQT_TQWIDGET(label), 1, 1, Qt::AlignLeft);

  d->htmlName = new KLineEdit( page );
  d->htmlName->setMaxLength( 13 ); // Qt's TQColor allows 12 hexa-digits
  d->htmlName->setText("#FFFFFF"); // But HTML uses only 6, so do not worry about the size
  w = d->htmlName->fontMetrics().width(TQString::fromLatin1("#DDDDDDD"));
  d->htmlName->setFixedWidth(w);
  l_grid->addWidget(TQT_TQWIDGET(d->htmlName), 1, 2, Qt::AlignLeft);

  connect( d->htmlName, TQT_SIGNAL( textChanged(const TQString &) ),
      TQT_SLOT( slotHtmlChanged() ) );

  d->patch = new KColorPatch( page );
  d->patch->setFixedSize(48, 48);
  l_grid->addMultiCellWidget(TQT_TQWIDGET(d->patch), 0, 1, 0, 0, Qt::AlignHCenter | Qt::AlignVCenter);
  connect( d->patch, TQT_SIGNAL( colorChanged( const TQColor&)),
	   TQT_SLOT( setColor( const TQColor&)));

  tl_layout->activate();
  page->setMinimumSize( page->sizeHint() );

  readSettings();
  d->bRecursion = false;
  d->bEditHsv = false;
  d->bEditRgb = false;
  d->bEditHtml = false;

  disableResize();
  KColor col;
  col.setHsv( 0, 0, 255 );
  _setColor( col );

  d->htmlName->installEventFilter(this);
  d->hsSelector->installEventFilter(this);
  d->hsSelector->setAcceptDrops(true);
}
Example #7
0
ControlWidget::ControlWidget( Database *database, PartymanConfigDialog *config,
                              PartymanMainWindow *parent )
: QWidget( parent )
, mpConfig( config )
, mpPlaylist( parent )
, mpSatellite( Satellite::get() )
, mpGenericSatelliteHandler( 0 )
, mPartymanIcon( QIcon( ":/Partyman/Icon.png" ) )
, mStopIcon( QCommonStyle().standardIcon(QStyle::SP_MediaStop) /*QIcon(":/Stop.png")*/ )
, mPlayIcon( QCommonStyle().standardIcon(QStyle::SP_MediaPlay) /*QIcon(":/Play.png")*/ )
, mPauseIcon( QCommonStyle().standardIcon(QStyle::SP_MediaPause) /*QIcon(":/Pause.png")*/ )
, mSkipIcon( QCommonStyle().standardIcon(QStyle::SP_MediaSkipForward) /*QIcon(":/Skip.png")*/ )
, mLoadIcon( QIcon( ":/Partyman/Load.png" ) )
, mpSettingsButton( new QPushButton( tr("Settings"), this ) )
, mpStartButton( new QToolButton( /*tr("Connect"),*/ this ) )
, mpSkipButton( new QToolButton( /*mSkipIcon, tr("Next"),*/ this ) )
, mpTrayIcon( new QSystemTrayIcon( this ) )
, mpTrayIconStopMenu( new QMenu( this ) )
, mpTrayIconPlayMenu( new QMenu( this ) )
, mpStartButtonMenu( new QMenu( mpStartButton ) )
, mpPlayAction( mpTrayIconStopMenu->addAction( mPlayIcon, tr("Start" ) ) )
, mpSkipAction( mpTrayIconPlayMenu->addAction( mSkipIcon, tr("Next" ) ) )
, mpPauseAction( mpStartButtonMenu->addAction( mPauseIcon, tr("Pause" ) ) )
, mpStopAction( mpStartButtonMenu->addAction( mStopIcon, tr("Disconnect" ) ) )
, mpLoadAction( mpStartButtonMenu->addAction( mLoadIcon, tr("Load" ) ) )
, mpTrayIconClickTimer( new QTimer( this ) )
, mConnected( false )
, mPaused( false )
, mKioskMode( false )
, mpDerMixDprocess( new QProcess( this ) )
, mpLoggerProcess( new QProcess( this ) )
, mWaitForDerMixD( false )
, mDerMixDstarted( false )
, mLastP0p()
{
   CrashCleanup::addObject( mpDerMixDprocess );
   setAcceptDrops( true );
   setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
   mpSettingsButton->setObjectName( QString("SettingsButton") );
   mpPlayer[0] = new PlayerWidget( 0, database, this );
   mpPlayer[1] = new PlayerWidget( 1, database, this );
   mpTrayIconClickTimer->setSingleShot( true );

   QGridLayout *mainLayout    = new QGridLayout( this );

   mainLayout->setContentsMargins( 3, 3, 3 ,3 );
   mainLayout->setSpacing( 5 );
   mainLayout->addWidget( mpPlayer[0],      1, 0, 4, 1 );
   mainLayout->addWidget( mpPlayer[1],      1, 2, 4, 1 );
   mainLayout->addWidget( mpSettingsButton, 1, 1 );
   mainLayout->addWidget( mpStartButton,  3, 1 );
   mainLayout->addWidget( mpSkipButton,     4, 1 );

   mainLayout->setColumnStretch( 0, 1 );
   mainLayout->setColumnStretch( 2, 1 );
   mainLayout->setRowStretch( 0, 1 );
   mainLayout->setRowStretch( 5, 1 );

   setLayout( mainLayout );

   mpStartButton->setDefaultAction( mpPlayAction );
   mpStartButton->setPopupMode( QToolButton::InstantPopup );
   mpStartButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
   mpStartButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
   mpPlayAction->setCheckable( true );
   mpPlayAction->setDisabled( true );

   mpSkipButton->setDefaultAction( mpSkipAction );
   mpSkipButton->setPopupMode( QToolButton::InstantPopup );
   mpSkipButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
   mpSkipButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
   mpSkipAction->setCheckable( true );
   mpSkipAction->setDisabled( true );

   mpTrayIcon->setIcon( QIcon(":/Partyman/Icon.png") );
   mpTrayIcon->setContextMenu( mpTrayIconStopMenu );
   mpTrayIconPlayMenu->addAction( mpPauseAction );
   mpTrayIconPlayMenu->addAction( mpStopAction );

   connect( mpSettingsButton, SIGNAL(clicked()),
            mpConfig, SLOT(exec()) );
   connect( mpStartButton, SIGNAL(clicked()),
            this, SLOT(initConnect()) );
   connect( mpPlayAction, SIGNAL(triggered()),
            this, SLOT(initConnect()) );
   connect( mpPauseAction, SIGNAL(triggered()),
            this, SLOT(handlePause()) );
   connect( mpStopAction, SIGNAL(triggered()),
            this, SLOT(initDisconnect()) );
   connect( mpLoadAction, SIGNAL(triggered()),
            this, SLOT(handleLoad()) );
   connect( mpSkipAction, SIGNAL(triggered()),
            this, SLOT(handleSkipTrack()) );
   connect( mpConfig, SIGNAL(configChanged()),
            this, SLOT(readConfig()) );
   connect( mpPlayer[0], SIGNAL(trackPlaying(TrackInfo)),
            this, SLOT(handleTrackPlaying(TrackInfo)) );
   connect( mpPlayer[1], SIGNAL(trackPlaying(TrackInfo)),
            this, SLOT(handleTrackPlaying(TrackInfo)) );
   connect( mpTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(handleTrayIcon(QSystemTrayIcon::ActivationReason)) );
   connect( mpTrayIconClickTimer, SIGNAL(timeout()),
            this, SLOT(handlePause()) );

   connect( mpDerMixDprocess, SIGNAL(readyReadStandardError()),
            this, SLOT(handleDerMixDstartup()) );
   connect( mpDerMixDprocess, SIGNAL(finished(int,QProcess::ExitStatus)),
            this, SLOT(handleDerMixDfinish(int,QProcess::ExitStatus)) );
   connect( mpDerMixDprocess, SIGNAL(error(QProcess::ProcessError)),
            this, SLOT(handleDerMixDerror(QProcess::ProcessError)) );

   if( mpSatellite )
   {
      mpGenericSatelliteHandler = new GenericSatelliteHandler( mpSatellite, GenericSatelliteHandler::WithPingAndDialog, this );
      connect( mpGenericSatelliteHandler, SIGNAL(updateConfig()),
               mpConfig, SLOT(readSettings()) );
      connect( mpGenericSatelliteHandler, SIGNAL(anotherInstance()),
               this, SLOT(initDisconnect()) );
      connect( mpSatellite, SIGNAL(received(QByteArray)),
               this, SLOT(handleSatellite(QByteArray)) );
   }
}
Example #8
0
MainWindow::MainWindow(QWidget* parent)
    : QMainWindow(parent), m_view(0)
{
    m_hostInfoManager = new HostInfoManager;

    m_monitor = new Monitor(m_hostInfoManager, this);

    m_viewMode = new QActionGroup(this);

    QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
    QAction* quitAction = fileMenu->addAction(tr("&Quit"));
    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
    QMenu* modeMenu = viewMenu->addMenu(tr("&Mode"));

    m_listView = modeMenu->addAction(tr("&List View"));
    m_listView->setCheckable(true);
    m_viewMode->addAction(m_listView);
    connect(m_listView, SIGNAL(triggered()), this, SLOT(setupListView()));

    m_starView = modeMenu->addAction(tr("&Star View"));
    m_starView->setCheckable(true);
    m_viewMode->addAction(m_starView);
    connect(m_starView, SIGNAL(triggered()), this, SLOT(setupStarView()));

    m_detailedView = modeMenu->addAction(tr("&Detailed Host View"));
    m_detailedView->setCheckable(true);
    m_viewMode->addAction(m_detailedView);
    connect(m_detailedView, SIGNAL(triggered()), this, SLOT(setupDetailedHostView()));


    QAction* actionStart = viewMenu->addAction(tr("&Start"));
    connect(actionStart, SIGNAL(triggered()), this, SLOT(startView()));
    QAction* actionStop = viewMenu->addAction(tr("Stop"));
    connect(actionStop, SIGNAL(triggered()), this, SLOT(stopView()));
    viewMenu->addSeparator();
    QAction* actionCheckNodes = viewMenu->addAction(tr("Check Nodes"));
    connect(actionCheckNodes, SIGNAL(triggered()), this, SLOT(checkNodes()));
    viewMenu->addSeparator();
    m_configView = viewMenu->addAction(tr("Configure View..."));
    connect(m_configView, SIGNAL(triggered()), this, SLOT( configureView()));

    m_systrayAction = viewMenu->addAction(tr("System Tray"));
    m_systrayAction->setCheckable(true);

    QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
    helpMenu->addAction(tr("About..."), this, SLOT(showAboutDialog()));

    readSettings();

    // Avoid useless creation and connection if the system does not have a systray
    if (QSystemTrayIcon::isSystemTrayAvailable()) {
        m_systemTrayIcon = new QSystemTrayIcon(this);
        m_systemTrayIcon->setIcon(QIcon(":bigIcon.png"));

        m_systemTrayMenu = new QMenu(this);
        m_systemTrayMenu->addAction(quitAction);

        m_systemTrayIcon->setContextMenu(m_systemTrayMenu);

        connect(m_systemTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
                this, SLOT(systemTrayIconActivated(QSystemTrayIcon::ActivationReason)));

        connect(m_systrayAction, SIGNAL(triggered(bool)), m_systemTrayIcon, SLOT(setVisible(bool)));

        // Only show the systray if enabled
        if (m_systrayAction->isChecked())
            m_systemTrayIcon->show();
    } else {
        m_systrayAction->setEnabled(false);
    }

    setWindowIcon(QIcon(":bigIcon.png"));

    m_monitor->checkScheduler();
}
Example #9
0
PlotArea::PlotArea(QWidget *parent)     : QWidget(parent)
{

	LambdaBox  = new QCheckBox(tr("Lambda"));
	RPMBox          = new QCheckBox(tr("RPM"));
	VEBox      = new QCheckBox(tr("VE"));
	MAPBox          = new QCheckBox(tr("MAP"));
	airTempBox = new QCheckBox(tr("Air Temp"));
	waterTempBox   = new QCheckBox(tr("Water Temp"));
	ignAdvanceBox  = new QCheckBox(tr("Ignition Advance"));
	fuelAdvBox = new QCheckBox(tr("Fuel Advance"));
	dutyBox    = new QCheckBox(tr("Duty %"));
	injTimeBox = new QCheckBox(tr("Inj Time"));
	throttleBox    = new QCheckBox(tr("Throttle pos"));

	readSettings();
	setBackgroundRole(QPalette::Base);
	setMinimumSize(100,100);
	setAutoFillBackground(true);
	BackColor.setRgb(255, 255, 255);
	penColor.setRgb(150, 150, 150);
	channel1Color.setRgb(0, 0, 0);
	//backBrush.setColor(BackColor);

	palette.setColor(backgroundRole(), BackColor);
	setPalette(palette);

	points = new QPoint[1100];
	const int base = height();	 //out of range
	for(int i=0;i<1100;++i)		 //width()-15;++i)
	{
		(points+i)->setX(i+25);
		(points+i)->setY(base);
	}
	channel = 3;
	reversed = true;
	scaleFactorX = 1;
	scaleFactorY = 1;
	rows = 9;
	columns = 15;
	xSize=300;
	ySize=200;
	pointsReceived = 0;

	for(int i=0;i<rows;++i)
	{
		scaleY[i] = (i) * scaleFactorY;
	}

	menu = new QMenu;

	selectChannelAct = new QAction(tr("Select channels"), this);
	connect(selectChannelAct, SIGNAL(triggered()), this, SLOT(chooseDialog()));

	menu->addAction(selectChannelAct);
	colors = menu->addMenu("Colors");
	backColorAct = colors->addAction(tr("Background"));
	fontColorAct = colors->addAction(tr("Font Color"));
	chan1ColorAct = colors->addAction(tr("Channel 1"));
	chan2ColorAct = colors->addAction(tr("Channel 2"));
	chan3ColorAct = colors->addAction(tr("Channel 3"));

	connect(backColorAct, SIGNAL(triggered()), this, SLOT(setBackColorSlot()));
	connect(fontColorAct, SIGNAL(triggered()), this, SLOT(setFontColorSlot()));
	connect(chan1ColorAct, SIGNAL(triggered()), this, SLOT(setChannel1ColorSlot()));
	connect(chan2ColorAct, SIGNAL(triggered()), this, SLOT(setBackColorSlot()));
	connect(chan3ColorAct, SIGNAL(triggered()), this, SLOT(setBackColorSlot()));

}
Example #10
0
int main(int argc, char **argv)
{
   SHA1Context sha;
   uint8_t *buf;
   uint8_t res[20];
   int i, j, k;
   FILE *fp = 0;
   settings_t theSettings;
   
   if (argc == 1) {
      usage(argv[0]);
      exit(1);
   }   
   
   defaultSettings(&theSettings);
   
   readSettings(&theSettings, argc, argv);
   printSettings(&theSettings, stdout);
   
   theSettings.hashEntries = (hashEntry *) malloc(sizeof(hashEntry) * theSettings.numHashes);
   
   memset(theSettings.hashEntries, 0x00, sizeof(hashEntry)*theSettings.numHashes);
   
   fp = fopen(theSettings.fileName, "rb");
   
   fseek(fp, theSettings.hashOffset, SEEK_SET);
   
   for (i = 0; i < theSettings.numHashes; i++) {
      //initHashEntry(&theSettings.hashEntries[i]);
      fread(theSettings.hashEntries[i].hash, sizeof(uint8_t), 20, fp);
      theSettings.hashEntries[i].hashOffset = ftell(fp);
      fseek(fp, theSettings.hashRelativeOffset, SEEK_CUR);
      printHashEntry(&theSettings.hashEntries[i], stdout);
   }
   
   
   buf = (uint8_t *) malloc(sizeof(uint8_t) * theSettings.maxHashLength);
   
   while (theSettings.curFileOffset < theSettings.maxFileOffset) {
      fseek(fp, theSettings.curFileOffset, SEEK_SET);
      fread(buf, sizeof(uint8_t), theSettings.maxHashLength, fp);
      
      // yeah okay so I should have called it "ts", wanna fight about it?
      for (theSettings.curHashLength = theSettings.minHashLength; theSettings.curHashLength <= theSettings.maxHashLength; theSettings.curHashLength++) {
         SHA1Reset(&sha);
	 SHA1Input(&sha, buf, theSettings.curHashLength);
	 SHA1Result(&sha, res);
	 for (i = 0; i < theSettings.numHashes; i++) {
	    k = 1;
	    for (j = 0; j < 20; j++) {
	       if (res[j] != theSettings.hashEntries[i].hash[j]) {
	          k = 0;
	       }
	    }
	    if (k) {
	       printf("-------------------------------------\nMatch Found!\nHash Entry #%d\n", i);
	       theSettings.hashEntries[i].fileOffset = theSettings.curFileOffset;
	       theSettings.hashEntries[i].hashSize = theSettings.curHashLength;
	       printHashEntry(&theSettings.hashEntries[i], stdout);
	       theSettings.curFileOffset += theSettings.curHashLength-1;
	    }
	 }
      }
      theSettings.curFileOffset++;
   }
}
Example #11
0
MainWindow::MainWindow() : QMainWindow(0)
{
    readSettings();

    QString lang = getSettingsGeneralLanguage();
    qDebug("language: %s", qPrintable(lang));
    if(lang == "system")
        lang = QLocale::system().languageToString(QLocale::system().language()).toLower();

    //Load translations for the Embroidermodder 2 GUI
    QTranslator translatorEmb;
    translatorEmb.load("translations/" + lang + "/embroidermodder2_" + lang);
    qApp->installTranslator(&translatorEmb);

    //Load translations for the commands
    QTranslator translatorCmd;
    translatorCmd.load("translations/" + lang + "/commands_" + lang);
    qApp->installTranslator(&translatorCmd);

    //Load translations provided by Qt - this covers dialog buttons and other common things.
    QTranslator translatorQt;
    translatorQt.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    qApp->installTranslator(&translatorQt);

    //Init
    mainWin = this;
    //Menus
    fileMenu     = new QMenu(tr("&File"),     this);
    editMenu     = new QMenu(tr("&Edit"),     this);
    viewMenu     = new QMenu(tr("&View"),     this);
    settingsMenu = new QMenu(tr("&Settings"), this);
    windowMenu   = new QMenu(tr("&Window"),   this);
    helpMenu     = new QMenu(tr("&Help"),     this);
    //SubMenus
    recentMenu   = new QMenu(tr("Open &Recent"), this);
    zoomMenu     = new QMenu(tr("&Zoom"),        this);
    panMenu      = new QMenu(tr("&Pan"),         this);
    //Toolbars
    toolbarFile       = addToolBar(tr("File"));
    toolbarEdit       = addToolBar(tr("Edit"));
    toolbarView       = addToolBar(tr("View"));
    toolbarZoom       = addToolBar(tr("Zoom"));
    toolbarPan        = addToolBar(tr("Pan"));
    toolbarIcon       = addToolBar(tr("Icon"));
    toolbarHelp       = addToolBar(tr("Help"));
    toolbarLayer      = addToolBar(tr("Layer"));
    toolbarProperties = addToolBar(tr("Properties"));
    toolbarText       = addToolBar(tr("Text"));
    toolbarPrompt     = addToolBar(tr("Command Prompt"));
    //Selectors
    layerSelector      = new QComboBox(this);
    colorSelector      = new QComboBox(this);
    linetypeSelector   = new QComboBox(this);
    lineweightSelector = new QComboBox(this);
    textFontSelector   = new QFontComboBox(this);
    textSizeSelector   = new QComboBox(this);

    numOfDocs = 0;
    docIndex = 0;

    shiftKeyPressedState = false;

    setWindowIcon(QIcon("icons/" + getSettingsGeneralIconTheme() + "/" + "app" + ".png"));

    //create the mdiArea
    QFrame* vbox = new QFrame(this);
    QVBoxLayout* layout = new QVBoxLayout(vbox);
    layout->setMargin(0);
    vbox->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
    mdiArea = new MdiArea(this, vbox);
    mdiArea->useBackgroundLogo(getSettingsGeneralMdiBGUseLogo());
    mdiArea->useBackgroundTexture(getSettingsGeneralMdiBGUseTexture());
    mdiArea->useBackgroundColor(getSettingsGeneralMdiBGUseColor());
    mdiArea->setBackgroundLogo(getSettingsGeneralMdiBGLogo());
    mdiArea->setBackgroundTexture(getSettingsGeneralMdiBGTexture());
    mdiArea->setBackgroundColor(QColor(getSettingsGeneralMdiBGColor()));
    mdiArea->setViewMode(QMdiArea::TabbedView);
    mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    mdiArea->setActivationOrder(QMdiArea::ActivationHistoryOrder);
    layout->addWidget(mdiArea);
    setCentralWidget(vbox);

    //create the Command Prompt
    prompt = new CmdPrompt(this);
    prompt->setFocus(Qt::OtherFocusReason);
    this->setFocusProxy(prompt);
    mdiArea->setFocusProxy(prompt);

    prompt->setPromptTextColor(QColor(getSettingsPromptTextColor()));
    prompt->setPromptBackgroundColor(QColor(getSettingsPromptBGColor()));

    connect(prompt, SIGNAL(startCommand(const QString&)), this, SLOT(runCommandMain(const QString&)));
    connect(prompt, SIGNAL(runCommand(const QString&, const QString&)), this, SLOT(runCommandPrompt(const QString&, const QString&)));

            connect(prompt, SIGNAL(deletePressed()),    this, SLOT(deletePressed()));
    //TODO: connect(prompt, SIGNAL(tabPressed()),       this, SLOT(someUnknownSlot()));
            connect(prompt, SIGNAL(escapePressed()),    this, SLOT(escapePressed()));
            connect(prompt, SIGNAL(F1Pressed()),        this, SLOT(help()));
    //TODO: connect(prompt, SIGNAL(F2Pressed()),        this, SLOT(floatHistory()));
    //TODO: connect(prompt, SIGNAL(F3Pressed()),        this, SLOT(toggleQSNAP()));
            connect(prompt, SIGNAL(F4Pressed()),        this, SLOT(toggleLwt())); //TODO: typically this is toggleTablet(), make F-Keys customizable thru settings
    //TODO: connect(prompt, SIGNAL(F5Pressed()),        this, SLOT(toggleISO()));
    //TODO: connect(prompt, SIGNAL(F6Pressed()),        this, SLOT(toggleCoords()));
            connect(prompt, SIGNAL(F7Pressed()),        this, SLOT(toggleGrid()));
    //TODO: connect(prompt, SIGNAL(F8Pressed()),        this, SLOT(toggleORTHO()));
    //TODO: connect(prompt, SIGNAL(F9Pressed()),        this, SLOT(toggleSNAP()));
    //TODO: connect(prompt, SIGNAL(F10Pressed()),       this, SLOT(togglePOLAR()));
    //TODO: connect(prompt, SIGNAL(F11Pressed()),       this, SLOT(toggleQTRACK()));
            connect(prompt, SIGNAL(F12Pressed()),       this, SLOT(toggleRuler()));
            connect(prompt, SIGNAL(cutPressed()),       this, SLOT(cut()));
            connect(prompt, SIGNAL(copyPressed()),      this, SLOT(copy()));
            connect(prompt, SIGNAL(pastePressed()),     this, SLOT(paste()));
            connect(prompt, SIGNAL(selectAllPressed()), this, SLOT(selectAll()));
            connect(prompt, SIGNAL(undoPressed()),      this, SLOT(undo()));
            connect(prompt, SIGNAL(redoPressed()),      this, SLOT(redo()));

            connect(prompt, SIGNAL(shiftPressed()),     this, SLOT(setShiftPressed()));
            connect(prompt, SIGNAL(shiftReleased()),    this, SLOT(setShiftReleased()));

    //create the Object Property Editor
    dockPropEdit = new PropertyEditor("icons/" + getSettingsGeneralIconTheme(), getSettingsSelectionModePickAdd(), prompt, this);
    addDockWidget(Qt::LeftDockWidgetArea, dockPropEdit);
    connect(dockPropEdit, SIGNAL(pickAddModeToggled()), this, SLOT(pickAddModeToggled()));

    //create the Command History Undo Editor
    dockUndoEdit = new UndoEditor("icons/" + getSettingsGeneralIconTheme(), prompt, this);
    addDockWidget(Qt::LeftDockWidgetArea, dockUndoEdit);

    //setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowTabbedDocks | QMainWindow::VerticalTabs); //TODO: Load these from settings
    //tabifyDockWidget(dockPropEdit, dockUndoEdit); //TODO: load this from settings

    //Javascript
    initMainWinPointer(this);

    engine = new QScriptEngine(this);
    engine->installTranslatorFunctions();
    debugger = new QScriptEngineDebugger(this);
    debugger->attachTo(engine);
    javaInitNatives(engine);

    //Load all commands in a loop
    QDir commandDir("commands");
    QStringList cmdList = commandDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
    foreach(QString cmdName, cmdList)
    {
        javaLoadCommand(cmdName);
    }
Example #12
0
bool ConfigSettings::readSettings(void) {
    return readSettings(DEFAULT_CONFIG_PATH);
}
BtSearchOptionsArea::BtSearchOptionsArea(QWidget *parent )
        : QWidget(parent) {
    initView();
    initConnections();
    readSettings();
}
EnvironmentSettingsDialog::EnvironmentSettingsDialog(QWidget* parent) :
   QDialog(parent),
   ui(new Ui::EnvironmentSettingsDialog)
{
   ui->setupUi(this);

   readSettings();

   QSettings settings(QSettings::IniFormat, QSettings::UserScope, "CSPSoftware", "NESICIDE");

   ui->settingsLocation->setText(QString("Currently reading settings from: ")+settings.fileName());
   
   QFileInfo toolchainInfo(qgetenv("CC65_HOME"));
   if ( toolchainInfo.exists() &&
        toolchainInfo.isDir() )
   {
     ui->toolchainLocation->setText(qgetenv("CC65_HOME"));
   }
   
   m_scintilla = new QsciScintilla();
   m_defaultLexer = new QsciLexerDefault();
   m_cc65Lexer = new QsciLexerCC65();
   m_ca65Lexer = new QsciLexerCA65();
   m_lexer = m_defaultLexer;

   setupCodeEditor(0);

   ui->example->addWidget(m_scintilla);
   adjustSize();

   ui->showWelcomeOnStart->setChecked(m_showWelcomeOnStart);
   ui->saveAllOnCompile->setChecked(m_saveAllOnCompile);
   ui->rememberWindowSettings->setChecked(m_rememberWindowSettings);
   ui->trackRecentProjects->setChecked(m_trackRecentProjects);

   ui->useInternalDB->setChecked(m_useInternalGameDatabase);
   ui->GameDatabasePathEdit->setText(m_gameDatabase);
   ui->GameDatabasePathButton->setEnabled(!m_useInternalGameDatabase);
   ui->GameDatabasePathEdit->setEnabled(!m_useInternalGameDatabase);

   ui->GameDatabase->setText(gameDatabase.getGameDBAuthor()+", "+gameDatabase.getGameDBTimestamp());

   ui->ROMPath->setText(m_romPath);
   ui->runRom->setChecked(m_runRomOnLoad);
   ui->followExecution->setChecked(m_followExecution);

   switch ( m_debuggerUpdateRate )
   {
      case 0:
         ui->debuggerUpdateRate->setValue(0);
      break;
      case -1:
         ui->debuggerUpdateRate->setValue(2);
      break;
      case 1:
         ui->debuggerUpdateRate->setValue(1);
      break;
      default:
         ui->debuggerUpdateRate->setValue(2);
      break;
   }
   ui->debuggerUpdateRateMsg->setText(debuggerUpdateRateMsgs[ui->debuggerUpdateRate->value()]);

   ui->soundBufferDepth->setValue(m_soundBufferDepth);
   ui->soundBufferDepthMsg->setText(soundBufferDepthMsgs[(m_soundBufferDepth/1024)-1]);

   ui->showHighlightBar->setChecked(m_highlightBarEnabled);
   ui->showLineNumberMargin->setChecked(m_lineNumbersEnabled);

   ui->autoIndent->setChecked(m_autoIndentEnabled);
   ui->replaceTabs->setChecked(m_tabReplacementEnabled);
   ui->spacesForTab->setValue(m_spacesForTabs);

   ui->annotate->setChecked(m_annotateSource);
   
   ui->fold->setChecked(m_foldSource);

   ui->showSymbolTips->setChecked(m_showSymbolTips);
   ui->showOpcodeTips->setChecked(m_showOpcodeTips);

   ui->sourceExtensionsC->setText(m_cSourceExtensions);
   ui->sourceExtensionsAsm->setText(m_asmSourceExtensions);
   ui->headerExtensions->setText(m_headerExtensions);
   ui->highlightAsC->setText(m_highlightAsC);
   ui->highlightAsASM->setText(m_highlightAsASM);

   ui->eolMode->setCurrentIndex(m_eolMode);
   ui->eolConsistent->setChecked(m_eolForceConsistent);

   pageMap.insert("General",ui->general);
   pageMap.insert("Code Editor",ui->codeeditor);
   pageMap.insert("Compiler",ui->compiler);
   pageMap.insert("Nintendo Entertainment System",ui->nesemulator);
   pageMap.insert("NES Emulation",ui->nesemulator);
   pageMap.insert("Debugging",ui->nesdebugger);
   pageMap.insert("Commodore 64",ui->c64emulator);
   pageMap.insert("C=64 Emulation",ui->c64emulator);

   ui->treeWidget->setCurrentItem(ui->treeWidget->findItems("General",Qt::MatchExactly).at(0));
   if ( !nesicideProject->getProjectTarget().compare("nes",Qt::CaseInsensitive) )
   {
      ui->treeWidget->findItems("Commodore 64",Qt::MatchExactly).at(0)->setHidden(true);
   }
   else if ( !nesicideProject->getProjectTarget().compare("c64",Qt::CaseInsensitive) )
   {
      ui->treeWidget->findItems("Nintendo Entertainment System",Qt::MatchExactly).at(0)->setHidden(true);
   }
}
Example #15
0
DrumrollEditor::DrumrollEditor(QWidget* parent)
   : QMainWindow(parent)
      {
      setObjectName("Drumroll");
      setWindowTitle(QString("MuseScore"));
//      setIconSize(QSize(preferences.iconWidth, preferences.iconHeight));

      QWidget* mainWidget = new QWidget;
      QGridLayout* layout = new QGridLayout;
      mainWidget->setLayout(layout);
      layout->setSpacing(0);

      QToolBar* tb = addToolBar(tr("Toolbar 1"));
      tb->addAction(getAction("undo"));
      tb->addAction(getAction("redo"));
      tb->addSeparator();
#ifdef HAS_MIDI
      tb->addAction(getAction("midi-on"));
#endif
      QAction* a = getAction("follow");
      a->setCheckable(true);
      a->setChecked(preferences.followSong);

      tb->addAction(a);

      tb->addSeparator();
      tb->addAction(getAction("rewind"));
      tb->addAction(getAction("play"));
      tb->addSeparator();

      //-------------
      tb = addToolBar(tr("Toolbar 3"));
      layout->addWidget(tb, 1, 0, 1, 2);

      for (int i = 0; i < VOICES; ++i) {
            QToolButton* b = new QToolButton(this);
            b->setToolButtonStyle(Qt::ToolButtonTextOnly);
            QPalette p(b->palette());
            p.setColor(QPalette::Base, MScore::selectColor[i]);
            b->setPalette(p);
            QAction* a = getAction(voiceActions[i]);
            b->setDefaultAction(a);
            tb->addWidget(b);
            }

      tb->addSeparator();
      tb->addWidget(new QLabel(tr("Cursor:")));
      pos = new Awl::PosLabel;
      tb->addWidget(pos);
      Awl::PitchLabel* pl = new Awl::PitchLabel();
      tb->addWidget(pl);

      tb->addSeparator();
      tb->addWidget(new QLabel(tr("Velocity:")));
      veloType = new QComboBox;
      veloType->addItem(tr("offset"), int(Note::ValueType::OFFSET_VAL));
      veloType->addItem(tr("user"),   int(Note::ValueType::USER_VAL));
      tb->addWidget(veloType);

      velocity = new QSpinBox;
      velocity->setRange(-1, 127);
      velocity->setSpecialValueText("--");
      velocity->setReadOnly(true);
      tb->addWidget(velocity);

      tb->addWidget(new QLabel(tr("Pitch:")));
      pitch = new Awl::PitchEdit;
      pitch->setReadOnly(true);
      tb->addWidget(pitch);

      double xmag = .1;
      gv  = new DrumView;
      gv->scale(xmag, 1.0);
      layout->addWidget(gv, 3, 1);

      ruler = new Ruler;
      ruler->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
      ruler->setFixedHeight(rulerHeight);
      ruler->setMag(xmag, 1.0);

      layout->addWidget(ruler, 2, 1);

      Piano* piano = new Piano;
      piano->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
      piano->setFixedWidth(pianoWidth);
      layout->addWidget(piano, 3, 0);

      setCentralWidget(mainWidget);

      connect(gv->verticalScrollBar(), SIGNAL(valueChanged(int)), piano, SLOT(setYpos(int)));
      connect(gv->horizontalScrollBar(), SIGNAL(valueChanged(int)), ruler, SLOT(setXpos(int)));
      connect(gv,          SIGNAL(xposChanged(int)),           ruler, SLOT(setXpos(int)));
      connect(gv,          SIGNAL(magChanged(double,double)),  ruler, SLOT(setMag(double,double)));
      connect(gv,          SIGNAL(magChanged(double,double)),  piano, SLOT(setMag(double,double)));
      connect(gv,          SIGNAL(pitchChanged(int)),          pl,    SLOT(setPitch(int)));
      connect(gv,          SIGNAL(pitchChanged(int)),          piano, SLOT(setPitch(int)));
      connect(piano,       SIGNAL(pitchChanged(int)),          pl,    SLOT(setPitch(int)));
      connect(gv,          SIGNAL(posChanged(const Pos&)),     pos,   SLOT(setValue(const Pos&)));
      connect(gv,          SIGNAL(posChanged(const Pos&)),     ruler, SLOT(setPos(const Pos&)));
      connect(ruler,       SIGNAL(posChanged(const Pos&)),     pos,   SLOT(setValue(const Pos&)));
      connect(ruler,       SIGNAL(locatorMoved(int)),                 SLOT(moveLocator(int)));
      connect(veloType,    SIGNAL(activated(int)),                    SLOT(veloTypeChanged(int)));
      connect(velocity,    SIGNAL(valueChanged(int)),                 SLOT(velocityChanged(int)));
      connect(gv->scene(), SIGNAL(selectionChanged()),                SLOT(selectionChanged()));
      connect(piano,       SIGNAL(keyPressed(int)),                   SLOT(keyPressed(int)));
      connect(piano,       SIGNAL(keyReleased(int)),                  SLOT(keyReleased(int)));
      resize(800, 400);

      QActionGroup* ag = new QActionGroup(this);
      a = new QAction(this);
      a->setData("delete");
      a->setShortcut(Qt::Key_Delete);
      ag->addAction(a);
      addActions(ag->actions());
      connect(ag, SIGNAL(triggered(QAction*)), SLOT(cmd(QAction*)));

      readSettings();
      }
Example #16
0
UEFITool::UEFITool(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::UEFITool),
    version(tr("0.20.7"))
{
    clipboard = QApplication::clipboard();

    // Create UI
    ui->setupUi(this);
    searchDialog = new SearchDialog(this);
    ffsEngine = NULL;

    // Set window title
    this->setWindowTitle(tr("UEFITool %1").arg(version));

    // Connect signals to slots
    connect(ui->actionOpenImageFile, SIGNAL(triggered()), this, SLOT(openImageFile()));
    connect(ui->actionOpenImageFileInNewWindow, SIGNAL(triggered()), this, SLOT(openImageFileInNewWindow()));
    connect(ui->actionSaveImageFile, SIGNAL(triggered()), this, SLOT(saveImageFile()));
    connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search()));
    connect(ui->actionExtract, SIGNAL(triggered()), this, SLOT(extractAsIs()));
    connect(ui->actionExtractBody, SIGNAL(triggered()), this, SLOT(extractBody()));
    connect(ui->actionInsertInto, SIGNAL(triggered()), this, SLOT(insertInto()));
    connect(ui->actionInsertBefore, SIGNAL(triggered()), this, SLOT(insertBefore()));
    connect(ui->actionInsertAfter, SIGNAL(triggered()), this, SLOT(insertAfter()));
    connect(ui->actionReplace, SIGNAL(triggered()), this, SLOT(replaceAsIs()));
    connect(ui->actionReplaceBody, SIGNAL(triggered()), this, SLOT(replaceBody()));
    connect(ui->actionRemove, SIGNAL(triggered()), this, SLOT(remove()));
    connect(ui->actionRebuild, SIGNAL(triggered()), this, SLOT(rebuild()));
    connect(ui->actionMessagesCopy, SIGNAL(triggered()), this, SLOT(copyMessage()));
    connect(ui->actionMessagesCopyAll, SIGNAL(triggered()), this, SLOT(copyAllMessages()));
    connect(ui->actionMessagesClear, SIGNAL(triggered()), this, SLOT(clearMessages()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
    connect(ui->actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(exit()));
    connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(writeSettings()));

    // Enable Drag-and-Drop actions
    this->setAcceptDrops(true);

    // Set current directory
    currentDir = ".";

    // Set monospace font for some controls
    QFont font("Courier New", 10);
#if defined Q_OS_OSX
    font = QFont("Menlo", 10);
#elif defined Q_OS_WIN
    font = QFont("Consolas", 9);
#endif
    ui->infoEdit->setFont(font);
    ui->messageListWidget->setFont(font);
    ui->structureTreeView->setFont(font);
    searchDialog->ui->guidEdit->setFont(font);
    searchDialog->ui->hexEdit->setFont(font);

    // Initialize non-persistent data
    init();

    // Read stored settings
    readSettings();
}
Example #17
0
int main(void) {
	acInit();
	gfxInitDefault();
	
	gfxSetDoubleBuffering(GFX_TOP, false);
	gfxSetDoubleBuffering(GFX_BOTTOM, false);
	
	if(setjmp(exitJmp)) goto exit;
	
	preRenderKeyboard();
	
	clearScreen();
	drawString(10, 10, "Initing FS...");
	gfxFlushBuffers();
	gfxSwapBuffers();
	
	fsInit();
	
	clearScreen();
	drawString(10, 10, "Initing SOC...");
	gfxFlushBuffers();
	gfxSwapBuffers();
	
	SOC_Initialize((u32 *)memalign(0x1000, 0x100000), 0x100000);
	
	u32 wifiStatus = 0;
	ACU_GetWifiStatus(NULL, &wifiStatus);
	if(!wifiStatus) {
		hang("No WiFi! Is your wireless slider on?");
	}
	
	clearScreen();
	drawString(10, 10, "Reading settings...");
	gfxFlushBuffers();
	gfxSwapBuffers();
	
	if(!readSettings()) {
		hang("Could not read 3DSController.ini!");
	}
	
	clearScreen();
	drawString(10, 10, "Connecting to %s on port %d...", settings.IPString, settings.port);
	gfxFlushBuffers();
	gfxSwapBuffers();
	
	openSocket(settings.port);
	sendConnectionRequest();
	
	clearScreen();
	gfxFlushBuffers();
	gfxSwapBuffers();
	
	disableBacklight();
	
	while(aptMainLoop()) {
		hidScanInput();
		irrstScanInput();
		
		u32 kHeld = hidKeysHeld();
		circlePosition circlePad;
		circlePosition cStick;
		hidCstickRead(&cStick);
		hidCircleRead(&circlePad);
		touchPosition touch;
		touchRead(&touch);
		
		clearScreen();
		
		if((kHeld & KEY_L) && (kHeld & KEY_R) && (kHeld & KEY_X)) {
			if(keyboardToggle) {
				keyboardActive = !keyboardActive;
				keyboardToggle = false;
				
				if(keyboardActive) enableBacklight();
			}
		}
		else keyboardToggle = true;
		
		if(keyboardActive) {
			drawKeyboard();
			
			if(touch.px >= 1 && touch.px <= 312 && touch.py >= 78 && touch.py <= 208) {
				int x = (int)((float)touch.px * 12.0f / 320.0f);
				int y = (int)((float)(touch.py - 78) * 12.0f / 320.0f);
				int width = 24;
				int height = 24;
				
				if(keyboardChars[x + y * 12] == ' ') {
					while(keyboardChars[(x - 1) + y * 12] == ' ') x--;
					
					width = (int)(5.0f * 320.0f / 12.0f) - 1;
				}
				
				else if(keyboardChars[x + y * 12] == '\13') {
					while(keyboardChars[(x - 1) + y * 12] == '\13') x--;
					while(keyboardChars[x + (y - 1) * 12] == '\13') y--;
					
					width = (int)(2.0f * 320.0f / 12.0f) - 1;
					height = (int)(3.0f * 320.0f / 12.0f) - 1;
				}
				
				if(keyboardChars[x + y * 12]) drawBox((int)((float)x * 320.0f / 12.0f) + 1, (int)(78.0f + (float)y * 320.0f / 12.0f) + 1, width, height, 31, 31, 0);
			}
		}
		
		sendKeys(kHeld, circlePad, touch, cStick);
		
		//receiveBuffer(sizeof(struct packet));
		
		if((kHeld & KEY_START) && (kHeld & KEY_SELECT)) longjmp(exitJmp, 1);
		
		gfxFlushBuffers();
		gspWaitForVBlank();
		gfxSwapBuffers();
	}
	
	exit:
	
	enableBacklight();
	
	SOC_Shutdown();
	
	svcCloseHandle(fileHandle);
	fsExit();
	
	gfxExit();
	acExit();
	
	return 0;
}
Example #18
0
SetupMisc::SetupMisc(QWidget* parent)
    : QScrollArea(parent), d(new SetupMiscPriv)
{
    QWidget* panel = new QWidget(viewport());
    setWidget(panel);
    setWidgetResizable(true);

    QVBoxLayout* layout = new QVBoxLayout(panel);

    // -- Misc Options --------------------------------------------------------

    QGroupBox* miscOptionsGroup = new QGroupBox(i18n("Behavior"), panel);
    QVBoxLayout* gLayout5       = new QVBoxLayout();

    d->useTrash         = new QCheckBox(i18n("&Deleted items should go to the trash"), miscOptionsGroup);
    d->showSplash       = new QCheckBox(i18n("&Show splash screen at startup"), miscOptionsGroup);

    KHBox* hbox         = new KHBox(miscOptionsGroup);
    d->sidebarTypeLabel = new QLabel(i18n("Sidebar tab title:"), hbox);
    d->sidebarType      = new KComboBox(hbox);
    d->sidebarType->addItem(i18n("Only For Active Tab"), 0);
    d->sidebarType->addItem(i18n("For All Tabs"),        1);
    d->sidebarType->setToolTip(i18n("Set this option to configure how sidebars tab title are visible."));

    gLayout5->addWidget(d->useTrash);
    gLayout5->addWidget(d->showSplash);
    gLayout5->addWidget(hbox);
    miscOptionsGroup->setLayout(gLayout5);

    // -- Sort Order Options --------------------------------------------------------

    QGroupBox* sortOptionsGroup = new QGroupBox(i18n("Sort order for images"), panel);
    QVBoxLayout* gLayout4       = new QVBoxLayout();

    KHBox* sortBox       = new KHBox(sortOptionsGroup);
    new QLabel(i18n("Sort images by:"), sortBox);
    d->sortOrderComboBox = new KComboBox(sortBox);
    d->sortOrderComboBox->insertItem(SortByDate,     i18nc("sort images by date", "Date"));
    d->sortOrderComboBox->insertItem(SortByName,     i18nc("sort images by name", "Name"));
    d->sortOrderComboBox->insertItem(SortByFileSize, i18nc("sort images by size", "File Size"));
    d->sortOrderComboBox->setWhatsThis(i18n("Here, select whether newly-loaded "
                                            "images are sorted by their date, name, or size on disk."));

    d->sortReverse = new QCheckBox(i18n("Reverse ordering"), sortOptionsGroup);
    d->sortReverse->setWhatsThis(i18n("If this option is enabled, newly-loaded "
                                      "images will be sorted in descending order."));

    gLayout4->addWidget(sortBox);
    gLayout4->addWidget(d->sortReverse);
    sortOptionsGroup->setLayout(gLayout4);

    // --------------------------------------------------------

    layout->addWidget(miscOptionsGroup);
    layout->addWidget(sortOptionsGroup);
    layout->addStretch();
    layout->setSpacing(KDialog::spacingHint());
    layout->setMargin(KDialog::spacingHint());

    // --------------------------------------------------------

    readSettings();

    setAutoFillBackground(false);
    viewport()->setAutoFillBackground(false);
    panel->setAutoFillBackground(false);
}
Example #19
0
 /**
  * PaletteWindow constructor
  * 
  * 
  * @param parent 
  */
 PaletteWindow::PaletteWindow(QWidget *parent) : QMainWindow(parent) {
   readSettings();
   parent->installEventFilter(this);
   p_appName = parent->windowTitle().toStdString();
 }
void OutputPaneManager::init()
{
    ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
    const Context globalContext(Constants::C_GLOBAL);

    // Window->Output Panes
    ActionContainer *mpanes = ActionManager::createMenu(Constants::M_WINDOW_PANES);
    mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
    mpanes->menu()->setTitle(tr("Output &Panes"));
    mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup");
    mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup");

    Command *cmd;

    cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear", globalContext);
    m_clearButton->setDefaultAction(cmd->action());
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalContext);
    cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6")));
    m_prevToolButton->setDefaultAction(cmd->action());
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalContext);
    m_nextToolButton->setDefaultAction(cmd->action());
    cmd->setDefaultKeySequence(QKeySequence(tr("F6")));
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalContext);
    cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+9") : tr("Alt+9")));
    cmd->setAttribute(Command::CA_UpdateText);
    cmd->setAttribute(Command::CA_UpdateIcon);
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
    connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
    m_minMaxButton->setDefaultAction(cmd->action());

    mpanes->addSeparator(globalContext, "Coreplugin.OutputPane.ActionsGroup");

    QFontMetrics titleFm = m_titleLabel->fontMetrics();
    int minTitleWidth = 0;

    m_panes = ExtensionSystem::PluginManager::getObjects<IOutputPane>();
    qSort(m_panes.begin(), m_panes.end(), &comparePanes);
    const int n = m_panes.size();

    int shortcutNumber = 1;
    const Id baseId = "QtCreator.Pane.";
    for (int i = 0; i != n; ++i) {
        IOutputPane *outPane = m_panes.at(i);
        const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this));
        QTC_CHECK(idx == i);

        connect(outPane, SIGNAL(showPage(int)), this, SLOT(showPage(int)));
        connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide()));
        connect(outPane, SIGNAL(togglePage(int)), this, SLOT(togglePage(int)));
        connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState()));
        connect(outPane, SIGNAL(flashButton()), this, SLOT(flashButton()));
        connect(outPane, SIGNAL(setBadgeNumber(int)), this, SLOT(setBadgeNumber(int)));

        QWidget *toolButtonsContainer = new QWidget(m_opToolBarWidgets);
        QHBoxLayout *toolButtonsLayout = new QHBoxLayout;
        toolButtonsLayout->setMargin(0);
        toolButtonsLayout->setSpacing(0);
        foreach (QWidget *toolButton, outPane->toolBarWidgets())
            toolButtonsLayout->addWidget(toolButton);
        toolButtonsLayout->addStretch(5);
        toolButtonsContainer->setLayout(toolButtonsLayout);

        m_opToolBarWidgets->addWidget(toolButtonsContainer);

        minTitleWidth = qMax(minTitleWidth, titleFm.width(outPane->displayName()));

        QString suffix = outPane->displayName().simplified();
        suffix.remove(QLatin1Char(' '));
        const Id id = baseId.withSuffix(suffix);
        QAction *action = new QAction(outPane->displayName(), this);
        Command *cmd = ActionManager::registerAction(action, id, globalContext);

        mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
        m_actions.append(action);
        m_ids.append(id);

        cmd->setDefaultKeySequence(QKeySequence(paneShortCut(shortcutNumber)));
        OutputPaneToggleButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(),
                                                                    cmd->action());
        ++shortcutNumber;
        m_buttonsWidget->layout()->addWidget(button);
        m_buttons.append(button);
        connect(button, SIGNAL(clicked()), this, SLOT(buttonTriggered()));

        bool visible = outPane->priorityInStatusBar() != -1;
        button->setVisible(visible);

        connect(action, SIGNAL(triggered()), this, SLOT(shortcutTriggered()));
    }

    m_titleLabel->setMinimumWidth(minTitleWidth + m_titleLabel->contentsMargins().left()
                                  + m_titleLabel->contentsMargins().right());
    m_buttonsWidget->layout()->addWidget(m_manageButton);
    connect(m_manageButton, SIGNAL(clicked()), this, SLOT(popupMenu()));

    readSettings();
}
Example #21
0
KBannerSetup::KBannerSetup( QWidget *parent )
	: KDialog( parent)
	  , saver( 0 ), ed(0), speed( 50 )
{
	setButtons(Ok|Cancel|Help);
	setDefaultButton(Ok);
	setCaption(i18n( "Setup Banner Screen Saver" ));
	setModal(true);
	setButtonText( Help, i18n( "A&bout" ) );
	readSettings();

        QWidget *main = new QWidget(this);
	setMainWidget(main);

	QLabel *label;

	QVBoxLayout *tl = new QVBoxLayout( main );
	QHBoxLayout *tl1 = new QHBoxLayout();
	tl->addLayout(tl1);
	QVBoxLayout *tl11 = new QVBoxLayout();
	tl1->addLayout(tl11);

	QGroupBox *group = new QGroupBox( i18n("Font"), main );
        QVBoxLayout *vbox = new QVBoxLayout;
        group->setLayout(vbox);
        QGridLayout *gl = new QGridLayout();
        vbox->addLayout(gl);
        gl->setSpacing(spacingHint());

	label = new QLabel( i18n("Family:"), group );
	gl->addWidget(label, 1, 0);

	KFontComboBox* comboFonts = new KFontComboBox( group );
	comboFonts->setCurrentFont( fontFamily );
	gl->addWidget(comboFonts, 1, 1);
	connect( comboFonts, SIGNAL(currentFontChanged(QFont)),
			SLOT(slotFamily(QFont)) );

	label = new QLabel( i18n("Size:"), group );
	gl->addWidget(label, 2, 0);

	comboSizes = new QComboBox( group );
        comboSizes->setEditable( true );
        fillFontSizes();
	gl->addWidget(comboSizes, 2, 1);
	connect( comboSizes, SIGNAL(activated(int)), SLOT(slotSize(int)) );
	connect( comboSizes, SIGNAL(editTextChanged(QString)),
			SLOT(slotSizeEdit(QString)) );

	QCheckBox *cb = new QCheckBox( i18n("Bold"),
				       group );
	cb->setChecked( bold );
	connect( cb, SIGNAL(toggled(bool)), SLOT(slotBold(bool)) );
	gl->addWidget(cb, 3, 0);

	cb = new QCheckBox( i18n("Italic"), group );
	cb->setChecked( italic );
	gl->addWidget(cb, 3, 1);
	connect( cb, SIGNAL(toggled(bool)), SLOT(slotItalic(bool)) );

	label = new QLabel( i18n("Color:"), group );
	gl->addWidget(label, 4, 0);

	colorPush = new KColorButton( fontColor, group );
	gl->addWidget(colorPush, 4, 1);
	connect( colorPush, SIGNAL(changed(QColor)),
		 SLOT(slotColor(QColor)) );

        QCheckBox *cyclingColorCb=new QCheckBox(i18n("Cycling color"),group);
        cyclingColorCb->setMinimumSize(cyclingColorCb->sizeHint());
        gl->addWidget(cyclingColorCb, 5, 0,5,1);
        connect(cyclingColorCb,SIGNAL(toggled(bool)),this,SLOT(slotCyclingColor(bool)));
        cyclingColorCb->setChecked(cyclingColor);

	preview = new QWidget( main );
	preview->setFixedSize( 220, 170 );
        {
            QPalette palette;
            palette.setColor( preview->backgroundRole(), Qt::black );
            preview->setPalette( palette );
	    preview->setAutoFillBackground(true);
        }
	preview->show();    // otherwise saver does not get correct size
	saver = new KBannerSaver( preview->winId() );
	tl1->addWidget(preview);

	tl11->addWidget(group);

	label = new QLabel( i18n("Speed:"), main );
	tl11->addStretch(1);
	tl11->addWidget(label);

	QSlider *sb = new QSlider( Qt::Horizontal, main );
        sb->setMinimum(0);
        sb->setMaximum(100);
        sb->setPageStep(10);
        sb->setValue(speed);
	sb->setMinimumWidth( 180);
	sb->setFixedHeight(20);
        sb->setTickPosition(QSlider::TicksBelow);
        sb->setTickInterval(10);
	tl11->addWidget(sb);
	connect( sb, SIGNAL(valueChanged(int)), SLOT(slotSpeed(int)) );

	QHBoxLayout *tl2 = new QHBoxLayout;
	tl->addLayout(tl2);

	label = new QLabel( i18n("Message:"), main );
	tl2->addWidget(label);

	ed = new QLineEdit( main );
	tl2->addWidget(ed);
	ed->setText( message );
	connect( ed, SIGNAL(textChanged(QString)),
			SLOT(slotMessage(QString)) );

   QCheckBox *timeCb=new QCheckBox( i18n("Show current time"), main);
   timeCb->setFixedSize(timeCb->sizeHint());
   tl->addWidget(timeCb,0,Qt::AlignLeft);
   connect(timeCb,SIGNAL(toggled(bool)),this,SLOT(slotTimeToggled(bool)));
   timeCb->setChecked(showTime);
   connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
   connect(this,SIGNAL(helpClicked()),this,SLOT(slotHelp()));
   tl->addStretch();
}