Esempio n. 1
1
ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* parent )
    : QWidget( parent )
    , TomahawkUtils::DpiScaler( this )
    , ui( new Ui::ArtistInfoWidget )
    , m_artist( artist )
{
    m_widget = new QWidget;
    m_headerWidget = new BasicHeader;
    ui->setupUi( m_widget );

    {
        ui->relatedArtists->setAutoResize( true );
        ui->relatedArtists->setAutoFitItems( true );
        ui->relatedArtists->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
        ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
        ui->relatedArtists->setItemWidth( scaledX( 170 ) );

        m_relatedModel = new PlayableModel( ui->relatedArtists );
        ui->relatedArtists->setPlayableModel( m_relatedModel );
        ui->relatedArtists->proxyModel()->sort( -1 );
        ui->relatedArtists->setEmptyTip( tr( "Sorry, we could not find any related artists!" ) );

        TomahawkStyle::stylePageFrame( ui->relatedArtists );
        TomahawkStyle::stylePageFrame( ui->artistFrame );
        TomahawkStyle::styleScrollBar( ui->relatedArtists->verticalScrollBar() );
    }

    {
        ui->albums->setAutoResize( true );
        ui->albums->setAutoFitItems( false );
        ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
        ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
        ui->albums->setWrapping( false );
        ui->albums->setItemWidth( scaledX( 190 ) );
        ui->albums->proxyModel()->setHideDupeItems( true );
        ui->albums->delegate()->setWordWrapping( true );
        ui->albums->setFixedHeight( ui->albums->itemSize().height() + ui->albums->spacing() * 2 );

        m_albumsModel = new PlayableModel( ui->albums );
        ui->albums->setPlayableModel( m_albumsModel );
        ui->albums->proxyModel()->sort( -1 );
        ui->albums->setEmptyTip( tr( "Sorry, we could not find any albums for this artist!" ) );

        TomahawkStyle::stylePageFrame( ui->albumFrame );
        TomahawkStyle::styleScrollBar( ui->albums->verticalScrollBar() );
        TomahawkStyle::styleScrollBar( ui->albums->horizontalScrollBar() );
    }

    {
        ui->topHits->setAutoResize( true );
        ui->topHits->setAutoFitItems( false );
        ui->topHits->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
        ui->topHits->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
        ui->topHits->setWrapping( false );
        ui->topHits->setItemWidth( scaledX( 140 ) );
        ui->topHits->proxyModel()->setHideDupeItems( true );
        ui->topHits->delegate()->setWordWrapping( true );
        ui->topHits->delegate()->setShowBuyButtons( true );
        ui->topHits->setFixedHeight( ui->topHits->itemSize().height() + ui->topHits->spacing() * 2 );

        m_topHitsModel = new PlayableModel( ui->topHits );
        ui->topHits->setPlayableModel( m_topHitsModel );
        ui->topHits->proxyModel()->sort( -1 );
        ui->topHits->setEmptyTip( tr( "Sorry, we could not find any top hits for this artist!" ) );

        TomahawkStyle::stylePageFrame( ui->trackFrame );
    }

    {
        ui->biography->setObjectName( "biography" );
        ui->biography->setContentsMargins( 0, 0, 0, 0 );
        ui->biography->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
        ui->biography->page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAsNeeded );
        ui->biography->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
        ui->biography->installEventFilter( this );

        TomahawkStyle::stylePageWidget( ui->biography );
        TomahawkStyle::stylePageFrame( ui->bioFrame );

        connect( ui->biography, SIGNAL( linkClicked( QUrl ) ), SLOT( onBiographyLinkClicked( QUrl ) ) );

        QFont f = ui->topHitsMoreLabel->font();
        f.setWeight( QFont::Light );
        f.setPointSize( TomahawkUtils::defaultFontSize() + 1 );
        ui->topHitsMoreLabel->setFont( f );
        ui->albumsMoreLabel->setFont( f );

        connect( ui->albumsMoreLabel, SIGNAL( clicked() ), SLOT( onAlbumsMoreClicked() ) );
        connect( ui->topHitsMoreLabel, SIGNAL( clicked() ), SLOT( onTopHitsMoreClicked() ) );

        ui->cover->setFixedSize( scaled( QSize( 384, 384 ) ) );
    }

    {
        m_headerWidget->ui->anchor1Label->setText( tr( "Music" ) );
        m_headerWidget->ui->anchor2Label->setText( tr( "Biography" ) );
        m_headerWidget->ui->anchor3Label->setText( tr( "Related Artists" ) );
        m_headerWidget->ui->anchor1Label->show();
        m_headerWidget->ui->anchor2Label->show();
        m_headerWidget->ui->anchor3Label->show();

        QFontMetrics fm( m_headerWidget->ui->anchor1Label->font() );
        m_headerWidget->ui->anchor1Label->setFixedWidth( fm.width( m_headerWidget->ui->anchor1Label->text() ) + 16 );
        m_headerWidget->ui->anchor2Label->setFixedWidth( fm.width( m_headerWidget->ui->anchor2Label->text() ) + 16 );
        m_headerWidget->ui->anchor3Label->setFixedWidth( fm.width( m_headerWidget->ui->anchor3Label->text() ) + 16 );

        connect( m_headerWidget->ui->anchor1Label, SIGNAL( clicked() ), SLOT( onMusicAnchorClicked() ) );
        connect( m_headerWidget->ui->anchor2Label, SIGNAL( clicked() ), SLOT( onBioAnchorClicked() ) );
        connect( m_headerWidget->ui->anchor3Label, SIGNAL( clicked() ), SLOT( onRelatedArtistsAnchorClicked() ) );
    }

    m_stackedWidget = new QStackedWidget();

    {
        m_area = new QScrollArea();
        m_area->setWidgetResizable( true );
        m_area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
        m_area->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
        m_area->setWidget( m_widget );

        QPalette pal = palette();
        pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND );
        m_area->setPalette( pal );
        m_area->setAutoFillBackground( true );
        m_area->setFrameShape( QFrame::NoFrame );
        m_area->setAttribute( Qt::WA_MacShowFocusRect, 0 );

        m_stackedWidget->addWidget( m_area );

        connect( m_area->verticalScrollBar(), SIGNAL( valueChanged(int ) ), SLOT( onSliderValueChanged( int ) ) );
    }
    {
        ContextView* topHitsFullView = new ContextView( m_stackedWidget );
        topHitsFullView->setCaption( tr( "Songs" ) );
        topHitsFullView->setShowCloseButton( true );
        topHitsFullView->trackView()->setPlayableModel( m_topHitsModel );
        m_stackedWidget->addWidget( topHitsFullView );

        connect( topHitsFullView, SIGNAL( closeClicked() ), SLOT( onPageClosed() ) );
    }
    {
        GridView* albumsFullView = new GridView( m_stackedWidget );
        albumsFullView->delegate()->setWordWrapping( true );
        //        albumsFullView->setCaption( tr( "Albums" ) );
        //        albumsFullView->setShowCloseButton( true );
        albumsFullView->setPlayableModel( m_albumsModel );
        albumsFullView->proxyModel()->setHideDupeItems( true );

        CaptionLabel* captionLabel = new CaptionLabel( this );
        captionLabel->setText( tr( "Albums" ) );
        captionLabel->setShowCloseButton( true );

        QWidget* vbox = new QWidget;
        QPalette pal = vbox->palette();
        pal.setBrush( vbox->backgroundRole(), TomahawkStyle::PAGE_BACKGROUND );
        vbox->setPalette( pal );
        vbox->setAutoFillBackground( true );

        QVBoxLayout* vboxl = new QVBoxLayout;
        TomahawkUtils::unmarginLayout( vboxl );
        vboxl->setContentsMargins( 32, 32, 32, 32 );
        vboxl->setSpacing( scaledY( 8 ) );
        vbox->setLayout( vboxl );

        vboxl->addWidget( captionLabel );
        vboxl->addWidget( albumsFullView );
        vboxl->addStretch();
        vboxl->setStretchFactor( albumsFullView, 1 );

        m_stackedWidget->addWidget( vbox );

        connect( captionLabel, SIGNAL( clicked() ), SLOT( onPageClosed() ) );
    }

    {
        QVBoxLayout* layout = new QVBoxLayout();
        layout->addWidget( m_headerWidget );
        layout->addWidget( m_stackedWidget );
        setLayout( layout );
        TomahawkUtils::unmarginLayout( layout );
    }

    MetaPlaylistInterface* mpl = new MetaPlaylistInterface();
    mpl->addChildInterface( ui->relatedArtists->playlistInterface() );
    mpl->addChildInterface( ui->topHits->playlistInterface() );
    mpl->addChildInterface( ui->albums->playlistInterface() );
    m_plInterface = playlistinterface_ptr( mpl );

    onSliderValueChanged( 0 );

    TomahawkUtils::fixMargins( this );

    m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::Original, scaled( QSize( 48, 48 ) ) );
    load( artist );
}
Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
    WiresharkDialog(parent, cf),
    ui(new Ui::Iax2AnalysisDialog),
    port_src_fwd_(0),
    port_dst_fwd_(0),
    port_src_rev_(0),
    port_dst_rev_(0),
    save_payload_error_(TAP_IAX2_NO_ERROR)
{
    ui->setupUi(this);
    loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5);
    setWindowSubtitle(tr("IAX2 Stream Analysis"));

    ui->progressFrame->hide();

    stream_ctx_menu_.addAction(ui->actionGoToPacket);
    stream_ctx_menu_.addAction(ui->actionNextProblem);
    stream_ctx_menu_.addSeparator();
    stream_ctx_menu_.addAction(ui->actionSaveAudio);
    stream_ctx_menu_.addAction(ui->actionSaveForwardAudio);
    stream_ctx_menu_.addAction(ui->actionSaveReverseAudio);
    stream_ctx_menu_.addSeparator();
    stream_ctx_menu_.addAction(ui->actionSaveCsv);
    stream_ctx_menu_.addAction(ui->actionSaveForwardCsv);
    stream_ctx_menu_.addAction(ui->actionSaveReverseCsv);
    stream_ctx_menu_.addSeparator();
    stream_ctx_menu_.addAction(ui->actionSaveGraph);
    ui->forwardTreeWidget->installEventFilter(this);
    ui->forwardTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->forwardTreeWidget, SIGNAL(customContextMenuRequested(QPoint)),
                SLOT(showStreamMenu(QPoint)));
    ui->reverseTreeWidget->installEventFilter(this);
    ui->reverseTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->reverseTreeWidget, SIGNAL(customContextMenuRequested(QPoint)),
                SLOT(showStreamMenu(QPoint)));
    connect(ui->streamGraph, SIGNAL(mousePress(QMouseEvent*)),
            this, SLOT(graphClicked(QMouseEvent*)));

    graph_ctx_menu_.addAction(ui->actionSaveGraph);

    QStringList header_labels;
    for (int i = 0; i < ui->forwardTreeWidget->columnCount(); i++) {
        header_labels << ui->forwardTreeWidget->headerItem()->text(i);
    }
    ui->reverseTreeWidget->setHeaderLabels(header_labels);

    memset(&src_fwd_, 0, sizeof(address));
    memset(&dst_fwd_, 0, sizeof(address));
    memset(&src_rev_, 0, sizeof(address));
    memset(&dst_rev_, 0, sizeof(address));

    QList<QCheckBox *> graph_cbs = QList<QCheckBox *>()
            << ui->fJitterCheckBox << ui->fDiffCheckBox
            << ui->rJitterCheckBox << ui->rDiffCheckBox;

    for (int i = 0; i < num_graphs_; i++) {
        QCPGraph *graph = ui->streamGraph->addGraph();
        graph->setPen(QPen(ColorUtils::graphColor(i)));
        graph->setName(graph_cbs[i]->text());
        graphs_ << graph;
        graph_cbs[i]->setChecked(true);
        graph_cbs[i]->setIcon(StockIcon::colorIcon(ColorUtils::graphColor(i), QPalette::Text));
    }
    ui->streamGraph->xAxis->setLabel("Arrival Time");
    ui->streamGraph->yAxis->setLabel("Value (ms)");

    // We keep our temp files open for the lifetime of the dialog. The GTK+
    // UI opens and closes at various points.
    QString tempname = QString("%1/wireshark_iax2_f").arg(QDir::tempPath());
    fwd_tempfile_ = new QTemporaryFile(tempname, this);
    fwd_tempfile_->open();
    tempname = QString("%1/wireshark_iax2_r").arg(QDir::tempPath());
    rev_tempfile_ = new QTemporaryFile(tempname, this);
    rev_tempfile_->open();

    if (fwd_tempfile_->error() != QFile::NoError || rev_tempfile_->error() != QFile::NoError) {
        err_str_ = tr("Unable to save RTP data.");
        ui->actionSaveAudio->setEnabled(false);
        ui->actionSaveForwardAudio->setEnabled(false);
        ui->actionSaveReverseAudio->setEnabled(false);
    }

    QMenu *save_menu = new QMenu();
    save_menu->addAction(ui->actionSaveAudio);
    save_menu->addAction(ui->actionSaveForwardAudio);
    save_menu->addAction(ui->actionSaveReverseAudio);
    save_menu->addSeparator();
    save_menu->addAction(ui->actionSaveCsv);
    save_menu->addAction(ui->actionSaveForwardCsv);
    save_menu->addAction(ui->actionSaveReverseCsv);
    save_menu->addSeparator();
    save_menu->addAction(ui->actionSaveGraph);
    ui->buttonBox->button(QDialogButtonBox::Save)->setMenu(save_menu);

    ui->buttonBox->button(QDialogButtonBox::Close)->setDefault(true);

    resetStatistics();
    updateStatistics(); // Initialize stats if an error occurs

#if 0
    /* Only accept Voice or MiniPacket packets */
    const gchar filter_text[] = "iax2.call && (ip || ipv6)";
#else
    const gchar filter_text[] = "iax2 && (ip || ipv6)";
#endif
    dfilter_t *sfcode;
    gchar *err_msg;

    /* Try to compile the filter. */
    if (!dfilter_compile(filter_text, &sfcode, &err_msg)) {
        err_str_ = QString(err_msg);
        g_free(err_msg);
        updateWidgets();
        return;
    }

    if (!cap_file_.capFile() || !cap_file_.capFile()->current_frame) {
        err_str_ = tr("Please select an IAX2 packet.");
        save_payload_error_ = TAP_IAX2_NO_PACKET_SELECTED;
        updateWidgets();
        return;
    }

    frame_data *fdata = cap_file_.capFile()->current_frame;

    if (!cf_read_record(cap_file_.capFile(), fdata)) close();

    epan_dissect_t edt;

    epan_dissect_init(&edt, cap_file_.capFile()->epan, TRUE, FALSE);
    epan_dissect_prime_with_dfilter(&edt, sfcode);
    epan_dissect_run(&edt, cap_file_.capFile()->cd_t, &cap_file_.capFile()->rec,
                     frame_tvbuff_new_buffer(&cap_file_.capFile()->provider, fdata, &cap_file_.capFile()->buf),
                     fdata, NULL);

    // This shouldn't happen (the menu item should be disabled) but check anyway
    if (!dfilter_apply_edt(sfcode, &edt)) {
        epan_dissect_cleanup(&edt);
        dfilter_free(sfcode);
        err_str_ = tr("Please select an IAX2 packet.");
        save_payload_error_ = TAP_IAX2_NO_PACKET_SELECTED;
        updateWidgets();
        return;
    }

    dfilter_free(sfcode);

    /* ok, it is a IAX2 frame, so let's get the ip and port values */
    copy_address(&(src_fwd_), &(edt.pi.src));
    copy_address(&(dst_fwd_), &(edt.pi.dst));
    port_src_fwd_ = edt.pi.srcport;
    port_dst_fwd_ = edt.pi.destport;

    /* assume the inverse ip/port combination for the reverse direction */
    copy_address(&(src_rev_), &(edt.pi.dst));
    copy_address(&(dst_rev_), &(edt.pi.src));
    port_src_rev_ = edt.pi.destport;
    port_dst_rev_ = edt.pi.srcport;

#ifdef IAX2_RTP_STREAM_CHECK
    rtpstream_tapinfot tapinfo;

    /* Register the tap listener */
    memset(&tapinfo, 0, sizeof(rtpstream_tapinfot));
    tapinfo.tap_data = this;
    tapinfo.mode = TAP_ANALYSE;

//    register_tap_listener_rtp_stream(&tapinfo, NULL);
    /* Scan for RTP streams (redissect all packets) */
    rtpstream_scan(&tapinfo, cap_file_.capFile(), NULL);

    int num_streams = 0;
    GList *filtered_list = NULL;
    for (GList *strinfo_list = g_list_first(tapinfo.strinfo_list); strinfo_list; strinfo_list = g_list_next(strinfo_list)) {
        rtp_stream_info_t * strinfo = (rtp_stream_info_t*)(strinfo_list->data);
                 << address_to_qstring(&strinfo->dest_addr) << address_to_qstring(&src_rev_) << address_to_qstring(&dst_rev_);
        if (addresses_equal(&(strinfo->src_addr), &(src_fwd_))
            && (strinfo->src_port == port_src_fwd_)
            && (addresses_equal(&(strinfo->dest_addr), &(dst_fwd_)))
            && (strinfo->dest_port == port_dst_fwd_))
        {
            ++num_streams;
            filtered_list = g_list_prepend(filtered_list, strinfo);
        }

        if (addresses_equal(&(strinfo->src_addr), &(src_rev_))
            && (strinfo->src_port == port_src_rev_)
            && (addresses_equal(&(strinfo->dest_addr), &(dst_rev_)))
            && (strinfo->dest_port == port_dst_rev_))
        {
            ++num_streams;
            filtered_list = g_list_append(filtered_list, strinfo);
        }
    }
Esempio n. 3
0
void MainPanel::init()
{
    if (!db.init())
    {
        QMessageBox error;
        error.critical(0, "Error!", "An error occured while trying to load the database.");
        exit(EXIT_FAILURE);
        return;
    }

    stack = new QStackedWidget(this);

    QString style = getStylesheet(":/Styles/Content.css");
    // Prepare UI objects for each tab
    libraryPtr = new Library(db);
    libraryPtr->setStyleSheet(style);
    browserPtr = new Browser();
    browserPtr->setStyleSheet(style);
    stack->addWidget(libraryPtr);
    stack->addWidget(browserPtr);
    stack->setCurrentWidget(libraryPtr);

    // System layout
    QHBoxLayout* systemLayout = new QHBoxLayout;
    systemLayout->setSpacing(0);
    systemLayout->setMargin(8);

    // Header spacing
    QVBoxLayout* topLayout = new QVBoxLayout;
    topLayout->setMargin(0);

    // Header layout
    QHBoxLayout* headerLayout = new QHBoxLayout;
    headerLayout->setSpacing(0);
    headerLayout->setMargin(0);

    // Window title
    QLabel* windowTitle = new QLabel(this);
    windowTitle->setObjectName("windowTitle");
    windowTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    windowTitle->setMinimumWidth(175);
    windowTitle->setMaximumWidth(175);
    windowTitle->setAlignment(Qt::AlignTop);
    windowTitle->setFont(QFont("Sansation", 18));
    windowTitle->setText("Project \nASCENSION");
    windowTitle->setStyleSheet("color: #7D818C;");
    windowTitle->setAttribute(Qt::WA_TransparentForMouseEvents);

    // Post-initialization header spacing
    topLayout->addLayout(systemLayout);
    topLayout->addLayout(headerLayout);
    topLayout->addSpacing(10);

    headerLayout->addSpacing(20);
    headerLayout->addWidget(windowTitle);
    headerLayout->addSpacing(40);

    // Header tabs
    libraryTab = new TabLabel(this);
    libraryTab = g_tabFactory(libraryTab, "libraryTab", "LIBRARY");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(libraryTab);
    libraryTab->setStyleSheet("font-weight: bold; color: lightgreen;");

    storeTab = new TabLabel(this);
    storeTab = g_tabFactory(storeTab, "storeTab", "  STORE");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(storeTab);

    modsTab = new TabLabel(this);
    modsTab = g_tabFactory(modsTab, "modsTab", " MODS");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(modsTab);

    newsTab = new TabLabel(this);
    newsTab = g_tabFactory(newsTab, "newsTab", "NEWS");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(newsTab);

    browserTab = new TabLabel(this);
    browserTab = g_tabFactory(browserTab, "browserTab", "BROWSER");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(browserTab);

    activeTab = libraryTab;

    headerLayout->addStretch();

    // System buttons
    systemLayout->addStretch();

    // Minimize
    QPushButton* pushButtonMinimize = new QPushButton("", this);
    pushButtonMinimize->setObjectName("pushButtonMinimize");
    systemLayout->addWidget(pushButtonMinimize);
    QObject::connect(pushButtonMinimize, SIGNAL(clicked()), this, SLOT(pushButtonMinimize()));

    // Maximize
    QPushButton* pushButtonMaximize = new QPushButton("", this);
    pushButtonMaximize->setObjectName("pushButtonMaximize");
    systemLayout->addWidget(pushButtonMaximize);
    QObject::connect(pushButtonMaximize, SIGNAL(clicked()), this, SLOT(pushButtonMaximize()));

    // Close
    QPushButton* pushButtonClose = new QPushButton("", this);
    pushButtonClose->setObjectName("pushButtonClose");
    systemLayout->addWidget(pushButtonClose);
    QObject::connect(pushButtonClose, SIGNAL(clicked()), this, SLOT(pushButtonClose()));

    // Main panel layout
    QGridLayout* mainGridLayout = new QGridLayout();
    mainGridLayout->setSpacing(0);
    mainGridLayout->setMargin(0);
    setLayout(mainGridLayout);

    // Central widget
    QWidget* centralWidget = new QWidget(this);
    centralWidget->setObjectName("centralWidget");
    centralWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    // Main panel scroll area
    QScrollArea* scrollArea = new QScrollArea(this);
    scrollArea->setWidgetResizable(true);
    scrollArea->setObjectName("mainPanelScrollArea");
    scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

    // Vertical layout example
    QVBoxLayout* verticalLayout = new QVBoxLayout();
    verticalLayout->setSpacing(5);
    verticalLayout->setMargin(0);
    verticalLayout->setAlignment(Qt::AlignHCenter);
    verticalLayout->addLayout(topLayout, 1);

    verticalLayout->addWidget(stack, 4);

    // Connect signals
    connect(libraryTab, SIGNAL(clicked()), this, SLOT(setTabLibrary()));
    connect(browserTab, SIGNAL(clicked()), this, SLOT(setTabBrowser()));

    // Show
    centralWidget->setLayout(verticalLayout);
    scrollArea->setWidget(centralWidget);
    mainGridLayout->addWidget(scrollArea);
}
void QLabelMouseTracking::createCropedScreenshot(QMouseEvent *ev)
{
    QWidget *mainWidget = this->parentWidget();
    mainWidget->hide();

    QPixmap pix =  QPixmap(); // clear image for low memory situations                            // on embedded devices.
    pix = QPixmap::grabWindow(QApplication::desktop()->winId());


    QRect geo = mainWidget->geometry();
    QPixmap pixCopy = pix.copy(geo.x(),geo.y(),geo.width(),geo.height());

    QString format = "png";
    QString pathPix = "d:/MyQT_Project";
    QString fileName;
    fileName = (QString::number(QDateTime::currentDateTime().toTime_t()));

    pixCopy.save(pathPix+ "/" + fileName+".png", format.toLatin1().constData());




    // Example %Path% + tesseract.exe  croppedImage.png test2 -eng
    // I used the escaped backslash, because slash didn't work

//    QString  foo = "\"d:\\MyQT_Project\\"; // The string contains spaces, that the reason für double qoutes
//    foo.append("tesseract.exe");
//    QString path = " d:\\MyQT_Project\\";

    QString  foo = "\"d:\\MyQT_Project\\"; // The string contains spaces, that the reason für double qoutes
    foo.append("tesseract.exe");
    QString path = "d:\\MyQT_Project\\";


    foo.append(path);
    foo.append(fileName);
    foo.append(".png");
    foo.append(path);
    foo.append(fileName); // The output file gets automatic a txt-Extension
    foo.append(" -eng\"");

    //foo = """d:\\MyQT_Project\\tesseract.exe  d:\\MyQT_Project\\1402617176.png d:\\MyQT_Project\\1402617176 -eng""";
    qDebug()<< foo;
    //process->start("cmd /k" + foo);
    //process->waitForFinished();

    QStringList args;
    args.append(path + fileName + ".png");
    args.append(path + fileName);
    args.append("-eng");

//    args.append(path + fileName + ".png");
//    args.append(path + fileName);
//    args.append(" -eng\"");
    qDebug()<< "QStringList" << args;
QProcess *process = new QProcess(this);




//    qDebug()<< "!!: " << process->isReadable();
//    qDebug()<< "??: " << process->isWritable();
    process->start("d:\\MyQT_Project\\tesseract.exe",args,QIODevice::ReadOnly);

    process->waitForFinished();

    QString txtFile = pathPix+ "/" + fileName+".txt";
    qDebug() << "Read txt: " << txtFile;


    //QThread *thread = new QThread(this);

//    while(true){
//        qDebug() << "READ";
//        if(file.exists(txtFile))break;
//        thread->sleep(1000);
//    }
    //thread->sleep(1000);
   // process->close();


QFile file(txtFile);

    QString doc;
    if(file.open(QIODevice::ReadOnly | QIODevice::Text)){

        QString line;
        QTextStream stream(&file);

        do{
            line = stream.readLine();
            doc += line;
            qDebug() << "Line " <<line;
        }while(! line.isNull());


        //The reason for no loop is, that the translation is in one line

    }
    file.close();
    qDebug() << "Was steht: " << doc;
    mainWidget->show();




//     QPointer<Translator> oo = this->tt;
//     if (oo.isNull()){
//         this->tt = new Translator();
//         qDebug() << "ififififif";
//     }else{
//         qDebug() << "elseelseelse";
//     }

//     tt->show();

     //tt->setTextToTranslate(doc);

    // Downcast mainWidget to get the reference of translator
    ImageCrop *ic  = qobject_cast<ImageCrop *>(mainWidget);
    ic->translator->setTextToTranslate(doc);



    //https://translate.google.de/#en/de/eaten
    //tWid->setTextToTranslate("https://translate.google.de/#en/de/" +doc);

//http://dict.leo.org/ende/index_de.html#/search=cinema&searchLoc=0&resultOrder=basic&multiwordShowSingle=on
}
/*!
  Insert a new item for a plot item
  \param plotItem Plot item
  \param legendItem New legend item
  \note The parent of item will be changed to QwtLegend::contentsWidget()
*/
void QwtLegend::insert(const QwtPlotItem *plotItem, QWidget *legendItem)
{
    if ( legendItem == NULL || plotItem == NULL )
        return;

    QWidget *contentsWidget = d_data->view->contentsWidget;

    if ( legendItem->parent() != contentsWidget )
    {
#if QT_VERSION >= 0x040000
        legendItem->setParent(contentsWidget);
#else
        legendItem->reparent(contentsWidget, QPoint(0, 0));
#endif
    }

    legendItem->show();

    d_data->map.insert(plotItem, legendItem);

    layoutContents();

    if ( contentsWidget->layout() )
    {
#if QT_VERSION >= 0x040000
        contentsWidget->layout()->addWidget(legendItem);
#endif

        // set tab focus chain

        QWidget *w = NULL;

#if QT_VERSION < 0x040000
        QLayoutIterator layoutIterator = 
            contentsWidget->layout()->iterator();
        for ( QLayoutItem *item = layoutIterator.current();
            item != 0; item = ++layoutIterator)
        {
#else
        for (int i = 0; i < contentsWidget->layout()->count(); i++)
        {
            QLayoutItem *item = contentsWidget->layout()->itemAt(i);
#endif
            if ( w && item->widget() )
            {
                QWidget::setTabOrder(w, item->widget());
                w = item->widget();
            }
        }
    }
    if ( parentWidget() && parentWidget()->layout() == NULL )
    {
       /*
          updateGeometry() doesn't post LayoutRequest in certain
          situations, like when we are hidden. But we want the
          parent widget notified, so it can show/hide the legend
          depending on its items.
        */
#if QT_VERSION < 0x040000
        QApplication::postEvent(parentWidget(),
            new QEvent(QEvent::LayoutHint));
#else
        QApplication::postEvent(parentWidget(),
            new QEvent(QEvent::LayoutRequest));
#endif
    }
}

/*!
  Find the widget that represents a plot item

  \param plotItem Plot item
  \return Widget on the legend, or NULL
*/
QWidget *QwtLegend::find(const QwtPlotItem *plotItem) const
{
    return d_data->map.find(plotItem);
}

/*!
  Find the widget that represents a plot item

  \param plotItem Plot item
  \return Widget on the legend, or NULL
*/
QwtPlotItem *QwtLegend::find(const QWidget *legendItem) const
{
    return d_data->map.find(legendItem);
}

/*! 
   Find the corresponding item for a plotItem and remove it 
   from the item list.

   \param plotItem Plot item
*/
void QwtLegend::remove(const QwtPlotItem *plotItem)
{ 
    QWidget *legendItem = d_data->map.find(plotItem);
    d_data->map.remove(legendItem); 
    delete legendItem;
}
Esempio n. 6
0
//!  Update the widget that represents the curve on the legend
void QwtPlotCurve::updateLegend(QwtLegend *legend) const
{
    if ( !legend )
        return;

    QwtPlotItem::updateLegend(legend);

    QWidget *widget = legend->find(this);
    if ( !widget || !widget->inherits("QwtLegendItem") )
        return;

    QwtLegendItem *legendItem = (QwtLegendItem *)widget;

#if QT_VERSION < 0x040000
    const bool doUpdate = legendItem->isUpdatesEnabled();
#else
    const bool doUpdate = legendItem->updatesEnabled();
#endif
    legendItem->setUpdatesEnabled(false);

    const int policy = legend->displayPolicy();

    if (policy == QwtLegend::FixedIdentifier)
    {
        int mode = legend->identifierMode();

        if (mode & QwtLegendItem::ShowLine)
            legendItem->setCurvePen(pen());

        if (mode & QwtLegendItem::ShowSymbol)
            legendItem->setSymbol(symbol());

        if (mode & QwtLegendItem::ShowText)
            legendItem->setText(title());
        else
            legendItem->setText(QwtText());

        legendItem->setIdentifierMode(mode);
    }
    else if (policy == QwtLegend::AutoIdentifier)
    {
        int mode = 0;

        if (QwtPlotCurve::NoCurve != style())
        {
            legendItem->setCurvePen(pen());
            mode |= QwtLegendItem::ShowLine;
        }
        if (QwtSymbol::NoSymbol != symbol().style())
        {
            legendItem->setSymbol(symbol());
            mode |= QwtLegendItem::ShowSymbol;
        }
        if ( !title().isEmpty() )
        {
            legendItem->setText(title());
            mode |= QwtLegendItem::ShowText;
        }
        else
        {
            legendItem->setText(QwtText());
        }
        legendItem->setIdentifierMode(mode);
    }

    legendItem->setUpdatesEnabled(doUpdate);
    legendItem->update();
}
Esempio n. 7
0
EditTagDialog::EditTagDialog(Application* app, QWidget* parent)
    : QDialog(parent),
      ui_(new Ui_EditTagDialog),
      app_(app),
      album_cover_choice_controller_(new AlbumCoverChoiceController(this)),
      loading_(false),
      abortRequested_(false),
      ignore_edits_(false),
      tag_fetcher_(new TagFetcher(this)),
      cover_art_id_(0),
      cover_art_is_set_(false),
      results_dialog_(new TrackSelectionDialog(this)) {
  QIcon nocover = IconLoader::Load("nocover", IconLoader::Other);
  cover_options_.default_output_image_ =
      AlbumCoverLoader::ScaleAndPad(cover_options_,
          nocover.pixmap(nocover.availableSizes().last())
                 .toImage());

  connect(app_->album_cover_loader(),
          SIGNAL(ImageLoaded(quint64, QImage, QImage)),
          SLOT(ArtLoaded(quint64, QImage, QImage)));

  connect(tag_fetcher_, SIGNAL(ResultAvailable(Song, SongList)),
          results_dialog_, SLOT(FetchTagFinished(Song, SongList)),
          Qt::QueuedConnection);
  connect(tag_fetcher_, SIGNAL(Progress(Song, QString)), results_dialog_,
          SLOT(FetchTagProgress(Song, QString)));
  connect(results_dialog_, SIGNAL(SongChosen(Song, Song)),
          SLOT(FetchTagSongChosen(Song, Song)));
  connect(results_dialog_, SIGNAL(finished(int)), tag_fetcher_, SLOT(Cancel()));
  album_cover_choice_controller_->SetApplication(app_);

  ui_->setupUi(this);
  ui_->splitter->setSizes(QList<int>() << 200 << width() - 200);
  ui_->loading_label->hide();

  ui_->fetch_tag->setIcon(IconLoader::Load("musicbrainz", 
                          IconLoader::Provider));

  // An editable field is one that has a label as a buddy.  The label is
  // important because it gets turned bold when the field is changed.
  for (QLabel* label : findChildren<QLabel*>()) {
    QWidget* widget = label->buddy();
    if (widget) {
      // Store information about the field
      fields_ << FieldData(label, widget, widget->objectName());

      // Connect the Reset signal
      if (dynamic_cast<ExtendedEditor*>(widget)) {
        connect(widget, SIGNAL(Reset()), SLOT(ResetField()));
      }

      // Connect the changed signal (emitted when value is changed
      // programmatically or non-programmatically)
      if (qobject_cast<QLineEdit*>(widget)) {
        connect(widget, SIGNAL(textChanged(QString)), SLOT(FieldValueEdited()));
      } else if (qobject_cast<QPlainTextEdit*>(widget)) {
        connect(widget, SIGNAL(textChanged()), SLOT(FieldValueEdited()));
      } else if (qobject_cast<QSpinBox*>(widget)) {
        connect(widget, SIGNAL(valueChanged(int)), SLOT(FieldValueEdited()));
      }
    }
  }

  // Set the colour of all the labels on the summary page
  const bool light = palette().color(QPalette::Base).value() > 128;
  const QColor color = palette().color(QPalette::WindowText);
  QPalette summary_label_palette(palette());
  summary_label_palette.setColor(
      QPalette::WindowText, light ? color.lighter(150) : color.darker(150));

  for (QLabel* label : ui_->summary_tab->findChildren<QLabel*>()) {
    if (label->property("field_label").toBool()) {
      label->setPalette(summary_label_palette);
    }
  }

  // Pretend the summary text is just a label
  ui_->summary->setMaximumHeight(ui_->art->height() -
                                 ui_->summary_art_button->height() - 4);

  connect(ui_->song_list->selectionModel(),
          SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
          SLOT(SelectionChanged()));
  connect(ui_->button_box, SIGNAL(clicked(QAbstractButton*)),
          SLOT(ButtonClicked(QAbstractButton*)));
  connect(ui_->rating, SIGNAL(RatingChanged(float)), SLOT(SongRated(float)));
  connect(ui_->playcount_reset, SIGNAL(clicked()), SLOT(ResetPlayCounts()));
  connect(ui_->fetch_tag, SIGNAL(clicked()), SLOT(FetchTag()));
  connect(ui_->abortSaveButton, SIGNAL(clicked()), SLOT(abortSave()));

  // Set up the album cover menu
  cover_menu_ = new QMenu(this);

  QList<QAction*> actions = album_cover_choice_controller_->GetAllActions();

  connect(album_cover_choice_controller_->cover_from_file_action(),
          SIGNAL(triggered()), this, SLOT(LoadCoverFromFile()));
  connect(album_cover_choice_controller_->cover_to_file_action(),
          SIGNAL(triggered()), this, SLOT(SaveCoverToFile()));
  connect(album_cover_choice_controller_->cover_from_url_action(),
          SIGNAL(triggered()), this, SLOT(LoadCoverFromURL()));
  connect(album_cover_choice_controller_->search_for_cover_action(),
          SIGNAL(triggered()), this, SLOT(SearchForCover()));
  connect(album_cover_choice_controller_->unset_cover_action(),
          SIGNAL(triggered()), this, SLOT(UnsetCover()));
  connect(album_cover_choice_controller_->show_cover_action(),
          SIGNAL(triggered()), this, SLOT(ShowCover()));

  cover_menu_->addActions(actions);

  ui_->summary_art_button->setMenu(cover_menu_);

  ui_->art->installEventFilter(this);
  ui_->art->setAcceptDrops(true);

  // Add the next/previous buttons
  previous_button_ = new QPushButton(
      IconLoader::Load("go-previous", IconLoader::Base), tr("Previous"), this);
  next_button_ = new QPushButton(IconLoader::Load("go-next", IconLoader::Base),
                                 tr("Next"), this);
  ui_->button_box->addButton(previous_button_, QDialogButtonBox::ResetRole);
  ui_->button_box->addButton(next_button_, QDialogButtonBox::ResetRole);

  connect(previous_button_, SIGNAL(clicked()), SLOT(PreviousSong()));
  connect(next_button_, SIGNAL(clicked()), SLOT(NextSong()));

  // Set some shortcuts for the buttons
  new QShortcut(QKeySequence::Back, previous_button_, SLOT(click()));
  new QShortcut(QKeySequence::Forward, next_button_, SLOT(click()));
  new QShortcut(QKeySequence::MoveToPreviousPage, previous_button_,
                SLOT(click()));
  new QShortcut(QKeySequence::MoveToNextPage, next_button_, SLOT(click()));

  // Show the shortcuts as tooltips
  previous_button_->setToolTip(QString("%1 (%2 / %3)").arg(
      previous_button_->text(),
      QKeySequence(QKeySequence::Back).toString(QKeySequence::NativeText),
      QKeySequence(QKeySequence::MoveToPreviousPage)
          .toString(QKeySequence::NativeText)));
  next_button_->setToolTip(QString("%1 (%2 / %3)").arg(
      next_button_->text(),
      QKeySequence(QKeySequence::Forward).toString(QKeySequence::NativeText),
      QKeySequence(QKeySequence::MoveToNextPage)
          .toString(QKeySequence::NativeText)));

  new TagCompleter(app_->library_backend(), Playlist::Column_Artist,
                   ui_->artist);
  new TagCompleter(app_->library_backend(), Playlist::Column_Album, ui_->album);
  new TagCompleter(app_->library_backend(), Playlist::Column_AlbumArtist,
                   ui_->albumartist);
  new TagCompleter(app_->library_backend(), Playlist::Column_Genre, ui_->genre);
  new TagCompleter(app_->library_backend(), Playlist::Column_Composer,
                   ui_->composer);
  new TagCompleter(app_->library_backend(), Playlist::Column_Performer,
                   ui_->performer);
  new TagCompleter(app_->library_backend(), Playlist::Column_Grouping,
                   ui_->grouping);
}
bool SceneViewer::event(QEvent *e) {
  if (e->type() == QEvent::ShortcutOverride || e->type() == QEvent::KeyPress) {
    if (!((QKeyEvent *)e)->isAutoRepeat()) {
      TApp::instance()->getCurrentTool()->storeTool();
    }
  }
  if (e->type() == QEvent::ShortcutOverride) {
    TTool *tool = TApp::instance()->getCurrentTool()->getTool();
    if (tool && tool->isEnabled() && tool->getName() == T_Type &&
        tool->isActive())
      e->accept();
    return true;
  }
  if (e->type() == QEvent::KeyRelease) {
    if (!((QKeyEvent *)e)->isAutoRepeat()) {
      QWidget *focusWidget = QApplication::focusWidget();
      if (focusWidget == 0 ||
          QString(focusWidget->metaObject()->className()) == "SceneViewer")
        TApp::instance()->getCurrentTool()->restoreTool();
    }
  }

  // discard too frequent move events
  static QTime clock;
  if (e->type() == QEvent::MouseButtonPress)
    clock.start();
  else if (e->type() == QEvent::MouseMove) {
    if (clock.elapsed() < 10) {
      e->accept();
      return true;
    }
    clock.start();
  }

  /*
switch(e->type())
{
case QEvent::Enter:
qDebug() << "************************** Enter";
break;
case QEvent::Leave:
qDebug() << "************************** Leave";
break;

case QEvent::TabletPress:
qDebug() << "************************** TabletPress"  << m_pressure;
break;
case QEvent::TabletMove:
qDebug() << "************************** TabletMove";
break;
case QEvent::TabletRelease:
qDebug() << "************************** TabletRelease";
break;


case QEvent::MouseButtonPress:
qDebug() << "**************************MouseButtonPress"  << m_pressure << " "
<< m_tabletEvent;
break;
case QEvent::MouseMove:
qDebug() << "**************************MouseMove" <<  m_pressure;
break;
case QEvent::MouseButtonRelease:
qDebug() << "**************************MouseButtonRelease";
break;

case QEvent::MouseButtonDblClick:
qDebug() << "============================== MouseButtonDblClick";
break;
}
*/

  return QGLWidget::event(e);
}
void MaterialAssignmentEditorWindow::create_widgets_for_side(
    QGridLayout*        parent,
    const int           row_index,
    const char*         slot_name,
    const Side          side)
{
    parent->addWidget(new QLabel(side == ObjectInstance::FrontSide ? "Front:" : "Back:"), row_index, 0, Qt::AlignRight);

    QHBoxLayout* layout = new QHBoxLayout();
    layout->setSpacing(6);

    QWidget* group = new QWidget();
    group->setLayout(new QHBoxLayout());
    group->layout()->setContentsMargins(0, 0, 0, 0);

    QComboBox* combo_box = 0;

    if (side == ObjectInstance::BackSide)
    {
        combo_box = new QComboBox();
        combo_box->addItem("Same As Front", "same");
        combo_box->addItem("None", "none");
        combo_box->addItem("Enabled", "enabled");
        combo_box->setCurrentIndex(-1);
        layout->addWidget(combo_box);

        new MouseWheelFocusEventFilter(combo_box);

        m_mode_combo_to_widget_group[combo_box] = group;

        const StringDictionary& front_mappings = m_object_instance.get_front_material_mappings();
        const StringDictionary& back_mappings = m_object_instance.get_back_material_mappings();

        if (!back_mappings.exist(slot_name))
        {
            combo_box->setCurrentIndex(combo_box->findData("none"));
            group->setEnabled(false);
        }
        else if (front_mappings.exist(slot_name) &&
                 front_mappings.get<string>(slot_name) == back_mappings.get<string>(slot_name))
        {
            combo_box->setCurrentIndex(combo_box->findData("same"));
            group->setEnabled(false);
        }
        else
        {
            combo_box->setCurrentIndex(combo_box->findData("enabled"));
            group->setEnabled(true);
        }

        connect(
            combo_box, SIGNAL(currentIndexChanged(int)),
            SLOT(slot_change_back_material_mode(int)));
    }

    QLineEdit* line_edit = new QLineEdit();
    group->layout()->addWidget(line_edit);

    const StringDictionary& mappings =
        side == ObjectInstance::FrontSide
            ? m_object_instance.get_front_material_mappings()
            : m_object_instance.get_back_material_mappings();

    if (m_object->get_material_slot_count() > 0)
    {
        if (mappings.exist(slot_name))
            line_edit->setText(mappings.get<QString>(slot_name));
    }
    else if (!mappings.empty())
    {
        line_edit->setText(mappings.begin().value<QString>());
    }

    connect(line_edit, SIGNAL(returnPressed()), SLOT(slot_apply()));

    QPushButton* browse_button = new QPushButton("Browse");
    browse_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    group->layout()->addWidget(browse_button);

    SlotInfo& slot_info = m_slot_infos[browse_button];
    slot_info.m_slot_name = slot_name;
    slot_info.m_side = side;
    slot_info.m_combo_box = combo_box;
    slot_info.m_line_edit = line_edit;

    connect(
        browse_button, SIGNAL(clicked()),
        SLOT(slot_open_entity_browser()));

    layout->addWidget(group);
    parent->addLayout(layout, row_index, 1);
}
//! [0]
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), completer(0), lineEdit(0)
{
    createMenu();

    QWidget *centralWidget = new QWidget;

    QLabel *modelLabel = new QLabel;
    modelLabel->setText(tr("Model"));

    modelCombo = new QComboBox;
    modelCombo->addItem(tr("QDirModel"));
    modelCombo->addItem(tr("QDirModel that shows full path"));
    modelCombo->addItem(tr("Country list"));
    modelCombo->addItem(tr("Word list"));
    modelCombo->setCurrentIndex(0);

    QLabel *modeLabel = new QLabel;
    modeLabel->setText(tr("Completion Mode"));
    modeCombo = new QComboBox;
    modeCombo->addItem(tr("Inline"));
    modeCombo->addItem(tr("Filtered Popup"));
    modeCombo->addItem(tr("Unfiltered Popup"));
    modeCombo->setCurrentIndex(1);

    QLabel *caseLabel = new QLabel;
    caseLabel->setText(tr("Case Sensitivity"));
    caseCombo = new QComboBox;
    caseCombo->addItem(tr("Case Insensitive"));
    caseCombo->addItem(tr("Case Sensitive"));
    caseCombo->setCurrentIndex(0);
//! [0]

//! [1]
    QLabel *maxVisibleLabel = new QLabel;
    maxVisibleLabel->setText(tr("Max Visible Items"));
    maxVisibleSpinBox = new QSpinBox;
    maxVisibleSpinBox->setRange(3,25);
    maxVisibleSpinBox->setValue(10);

    wrapCheckBox = new QCheckBox;
    wrapCheckBox->setText(tr("Wrap around completions"));
    wrapCheckBox->setChecked(true);
//! [1]

//! [2]
    contentsLabel = new QLabel;
    contentsLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    connect(modelCombo, SIGNAL(activated(int)), this, SLOT(changeModel()));
    connect(modeCombo, SIGNAL(activated(int)), this, SLOT(changeMode(int)));
    connect(caseCombo, SIGNAL(activated(int)), this, SLOT(changeCase(int)));
    connect(maxVisibleSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeMaxVisible(int)));
//! [2]

//! [3]
    lineEdit = new QLineEdit;
    
    QGridLayout *layout = new QGridLayout;
    layout->addWidget(modelLabel, 0, 0); layout->addWidget(modelCombo, 0, 1);
    layout->addWidget(modeLabel, 1, 0);  layout->addWidget(modeCombo, 1, 1);
    layout->addWidget(caseLabel, 2, 0);  layout->addWidget(caseCombo, 2, 1);
    layout->addWidget(maxVisibleLabel, 3, 0); layout->addWidget(maxVisibleSpinBox, 3, 1);
    layout->addWidget(wrapCheckBox, 4, 0);
    layout->addWidget(contentsLabel, 5, 0, 1, 2);
    layout->addWidget(lineEdit, 6, 0, 1, 2);
    centralWidget->setLayout(layout);
    setCentralWidget(centralWidget);

    changeModel();

    setWindowTitle(tr("Completer"));
    lineEdit->setFocus();
}
Esempio n. 11
0
void tst_QColumnView::scrollTo()
{
    QFETCH(bool, reverse);
    QFETCH(bool, giveFocus);
    if (reverse)
        qApp->setLayoutDirection(Qt::RightToLeft);
    ColumnView view;
    view.resize(200, 200);
    view.show();
    view.scrollTo(QModelIndex(), QAbstractItemView::EnsureVisible);
    QCOMPARE(view.HorizontalOffset(), 0);

    TreeModel model;
    view.setModel(&model);
    view.scrollTo(QModelIndex(), QAbstractItemView::EnsureVisible);

    QModelIndex home;
    home = model.index(0, 0, home);
    home = model.index(0, 0, home);
    home = model.index(0, 0, home);
    view.scrollTo(home, QAbstractItemView::EnsureVisible);
    QModelIndex homeFile = model.index(0, 0, home);
    view.setRootIndex(home);

    QModelIndex index = model.index(0, 0, home);
    view.scrollTo(index, QAbstractItemView::EnsureVisible);
    QCOMPARE(view.HorizontalOffset(), 0);

    // Embedded requires that at least one widget have focus
    QWidget w;
    w.show();

    if (giveFocus)
        view.setFocus(Qt::OtherFocusReason);
    else
        view.clearFocus();
    QTRY_COMPARE(view.hasFocus(), giveFocus);
    // scroll to the right
    int level = 0;
    int last = view.HorizontalOffset();
    while(model.hasChildren(index) && level < 5) {
        view.setCurrentIndex(index);
        QTest::qWait(ANIMATION_DELAY);
        view.scrollTo(index, QAbstractItemView::EnsureVisible);
        QTest::qWait(ANIMATION_DELAY);
        qApp->processEvents();
        index = model.index(0, 0, index);
        level++;
        if (level >= 2) {
            if (!reverse) {
                QTRY_VERIFY(view.HorizontalOffset() < 0);
                QTRY_VERIFY(last > view.HorizontalOffset());
            } else {
                QTRY_VERIFY(view.HorizontalOffset() > 0);
                QTRY_VERIFY(last < view.HorizontalOffset());
            }
        }
        last = view.HorizontalOffset();
    }

    // scroll to the left
    int start = level;
    while(index.parent().isValid() && index != view.rootIndex()) {
        view.setCurrentIndex(index);
        QTest::qWait(ANIMATION_DELAY);
        view.scrollTo(index, QAbstractItemView::EnsureVisible);
        index = index.parent();
        if (start != level) {
            if (!reverse)
                QTRY_VERIFY(last < view.HorizontalOffset());
            else
                QTRY_VERIFY(last > view.HorizontalOffset());
        }
        level--;
        last = view.HorizontalOffset();
    }
    // It shouldn't automatically steal focus if it doesn't have it
    QTRY_COMPARE(view.hasFocus(), giveFocus);

    // Try scrolling to something that is above the root index
    home = model.index(0, 0, QModelIndex());
    QModelIndex temp = model.index(1, 0, home);
    home = model.index(0, 0, home);
    home = model.index(0, 0, home);
    view.setRootIndex(home);
    view.scrollTo(model.index(0, 0, home));
    QTest::qWait(ANIMATION_DELAY);
    view.scrollTo(temp);
}
Esempio n. 12
0
KraftView::KraftView(QWidget *parent) :
  KraftViewBase( parent ),
  mHelpLabel( 0 ), mRememberAmount( -1 ), mModified( false )
{
  setCaption( i18n("Document" ) );
  setModal( false );
  setButtons( KDialog::Ok | KDialog::Cancel );
  m_type = ReadWrite;

  QWidget *w = new QWidget( this );

  QVBoxLayout *vLayoutGlobal = new QVBoxLayout;
  w->setLayout( vLayoutGlobal );
  setMainWidget( w );

  mDetailHeader = new QLabel;
  mDetailHeader->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) );
  mDetailHeader->setFrameStyle( QFrame::Box + QFrame::Plain );
  mDetailHeader->setLineWidth( 1 );
  mDetailHeader->setAutoFillBackground(true);

  mAddressProvider = new AddressProvider( this );
  connect( mAddressProvider, SIGNAL(addresseeFound( const QString&, const KABC::Addressee& )),
           this, SLOT( slotAddresseeFound( const QString&, const KABC::Addressee& )));


  QPalette palette;
  palette.setColor(mDetailHeader->backgroundRole(), QColor( "darkBlue" ));
  palette.setColor(mDetailHeader->foregroundRole(), QColor( "white "));
  mDetailHeader->setPalette( palette );
  mDetailHeader->setTextFormat( Qt::PlainText );
  mDetailHeader->setFixedHeight( 40 ); // FIXME
  QFont f = mDetailHeader->font();
  f.setPointSize( qRound( 1.4 * f.pointSize() ) );
  f.setBold( true );
  mDetailHeader->setFont( f );
  vLayoutGlobal->addWidget( mDetailHeader );

  mCSplit    = new QSplitter( w );
  vLayoutGlobal->addWidget( mCSplit );

  mViewStack = new QStackedWidget;
  mCSplit->addWidget( mViewStack );

  kDebug() << "mViewSTack height is " << mViewStack->height() << endl;

  mAssistant = new DocAssistant( mCSplit );
  mCSplit->addWidget( mAssistant );

  /* catalog template selection signal */
  connect( mAssistant,  SIGNAL( templatesToDocument(Katalog*,CatalogTemplateList) ),
           this,  SLOT( slotAddItems( Katalog*, CatalogTemplateList ) ) );

  /* signal to toggle the visibility of the template section in the assistant */
  connect(  mAssistant, SIGNAL( toggleShowTemplates( bool ) ),
            this,  SLOT( slotShowTemplates( bool ) ) );

  /* signal that brings a new address to the document */
  connect( mAssistant, SIGNAL( addressTemplate( const Addressee& ) ),
           this, SLOT( slotNewAddress( const Addressee& ) ) );

  connect( mAssistant, SIGNAL( headerTextTemplate( const QString& ) ),
           this, SLOT( slotNewHeaderText( const QString& ) ) );

  connect( mAssistant, SIGNAL( footerTextTemplate( const QString& ) ),
           this, SLOT( slotNewFooterText( const QString& ) ) );

  if ( KraftSettings::self()->docViewSplitter().count() == 2 ) {
    mCSplit->setSizes( KraftSettings::self()->docViewSplitter() );
  }
  connect( mAssistant, SIGNAL( selectPage( int ) ),
           this,  SLOT( slotSwitchToPage( int ) ) );

  QSize size = KraftSettings::self()->docViewSize();
  if ( !size.isEmpty() ) resize( size );
  QPoint pos = KraftSettings::self()->docViewPosition();
  if ( !pos.isNull() ) move( pos );

  mAssistant->slotSelectDocPart( KraftDoc::Header );

  setupMappers();

}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    //ui->setupUi(this);

    setFixedHeight(768); //1024
    setFixedWidth(768);

    //Define page structure
    QWidget * page = new QWidget(this);
    page->setFixedWidth(this->width());
    page->setFixedHeight(this->height());
    page->setStyleSheet("background-color:white;");
    QVBoxLayout * pageLayout = new QVBoxLayout();


    //Define the fixed header
    QWidget * header = new QWidget(page);
    header->setFixedWidth(page->width());
    QGridLayout * headerLayout = new QGridLayout();
    headerLayout->setHorizontalSpacing(2);
    headerLayout->setVerticalSpacing(2);

    QLabel * numTable = new QLabel();
    QPixmap numTableIm(":/Images/images/NumTable.png");
   // numTable->setStyleSheet("margin-right: 5px");
    numTable->setPixmap(numTableIm);
    numTable->setFixedSize(numTableIm.rect().size());

    QLabel * banner = new QLabel(header);
    QPixmap bannerIm(":/Images/images/Banner.png");
    banner->setPixmap(bannerIm);
    banner->setFixedSize(bannerIm.rect().size());

    QPushButton * pain = new QPushButton("");
    QPixmap painIm(":/Images/images/Pain.png");
    QIcon painIcon(painIm);
    pain->setIcon(painIcon);
    pain->setIconSize(painIm.rect().size());
    pain->setFixedSize(painIm.rect().size());

    QPushButton * eau = new QPushButton("");
    QPixmap eauIm(":/Images/images/eau.png");
    QIcon eauIcon(eauIm);
    eau->setIcon(eauIcon);
    eau->setIconSize(eauIm.rect().size());
    eau->setFixedSize(eauIm.rect().size());

    QPushButton * serveur = new QPushButton("");
    QPixmap serveurIm(":/Images/images/Serveur.png");
    QIcon serveurIcon(serveurIm);
    serveur->setIcon(serveurIcon);
    serveur->setIconSize(serveurIm.rect().size());
    serveur->setFixedSize(serveurIm.rect().size());


    headerLayout->addWidget(numTable, 0, 0, 2, 0);
    headerLayout->addWidget(banner, 0, 1, 2, 1);
    headerLayout->addWidget(serveur,0, 2, 2, 2);
    headerLayout->addWidget(pain, 0, 3);
    headerLayout->addWidget(eau, 1, 3);
    header->setLayout(headerLayout);


    //Define the widget containing all the meals (Tabs)
    QTabWidget * repasFrame = new QTabWidget(page);

    //For one Meal, define the widget containing all the bands
    QWidget * area = new QWidget(repasFrame);
    QScrollArea * sArea = new QScrollArea(area);
    QPalette * palette = new QPalette();
    palette->setColor(QPalette::Background, Qt::white);
    sArea->setPalette(*palette);
    sArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    sArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    sArea->setFixedWidth(page->width() -20);
    sArea->setFixedHeight(page->height() - header->height() - 125);

    bands = new QWidget();
    bands->setFixedWidth(page->width() -25);
   // bands->setMinimumHeight(page->height() - header->height() - 125);
    bands->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
    bandsLayout = new QVBoxLayout(bands);
    Headband* menus = HeadbandFactory::buildMenus(bands);
    bandList.append(menus);
    bandsLayout->addWidget(menus);
    usefulLabel = new QLabel();
    bandsLayout->addWidget(usefulLabel);
    bands->setLayout(bandsLayout);
    sArea->setWidget(bands);


    repasFrame->setFixedWidth(page->width());
    repasFrame->setFixedHeight(page->height() - header->height());
    repasFrame->addTab(area, "Repas 1");
    repasFrame->addTab(new QLabel(), "+");


    //Define the confirmation button
    QPushButton * confirmButton = new QPushButton("");
    QPixmap confirmIm(":/Images/images/Confirm.jpg");
    QIcon confirmIcon(confirmIm);
    confirmButton->setIcon(confirmIcon);
    confirmButton->setIconSize(confirmIm.rect().size());
    confirmButton->setFixedSize(confirmIm.rect().size());


    //Define the 'languette' and its 'etiquette'
    QList<QList<QObject*> > bigDataList;
    languetteContainer = new LanguetteContainer(bigDataList);
    languetteContainer->setFixedSize(760, 855);
    Etiquette * etiquette = new Etiquette(languetteContainer, confirmButton, page);


    //Link final page layouts
    pageLayout->addWidget(header);
    pageLayout->addWidget(repasFrame);
    pageLayout->addWidget(etiquette);
    pageLayout->addWidget(confirmButton);
    pageLayout->addWidget(languetteContainer);
    page->setLayout(pageLayout);


    //connect all slots
    connect(etiquette, SIGNAL(updateLanguetteInfo()), this, SLOT(recapLanguette()));
    connect(menus, SIGNAL(itemSelect(Headband_Item*)), this, SLOT(changeMenu(Headband_Item*)));
    connect(confirmButton, SIGNAL(clicked()), this, SLOT(confirmMeal()));
    connect(pain, SIGNAL(clicked()), this, SLOT(callBread()));
    connect(eau, SIGNAL(clicked()), this, SLOT(callWater()));
    connect(serveur, SIGNAL(clicked()), this, SLOT(callServer()));

    setCentralWidget(page);
}
void MusicWebDJRadioInfoWidget::createLabels()
{
    initFirstWidget();
    m_container->show();

    layout()->removeWidget(m_mainWindow);
    QScrollArea *scrollArea = new QScrollArea(this);
    scrollArea->verticalScrollBar()->setStyleSheet(MusicUIObject::MScrollBarStyle01);
    scrollArea->setWidgetResizable(true);
    scrollArea->setFrameShape(QFrame::NoFrame);
    scrollArea->setAlignment(Qt::AlignLeft);
    scrollArea->setWidget(m_mainWindow);
    layout()->addWidget(scrollArea);

    QWidget *function = new QWidget(m_mainWindow);
    function->setStyleSheet(MusicUIObject::MCheckBoxStyle01 + MusicUIObject::MPushButtonStyle03);
    QVBoxLayout *grid = new QVBoxLayout(function);

    QWidget *firstTopFuncWidget = new QWidget(function);
    QHBoxLayout *firstTopFuncLayout = new QHBoxLayout(firstTopFuncWidget);
    QLabel *firstLabel = new QLabel(function);
    firstLabel->setText(tr("<font color=#158FE1> DJRadio > %1 </font>").arg(m_currentPlaylistItem.m_name));
    QPushButton *backButton = new QPushButton(tr("Back"));
    backButton->setFixedSize(90, 30);
    backButton->setStyleSheet(MusicUIObject::MPushButtonStyle03);
    backButton->setCursor(QCursor(Qt::PointingHandCursor));
    connect(backButton, SIGNAL(clicked()), this, SIGNAL(backToMainMenu()));
    firstTopFuncLayout->addWidget(firstLabel);
    firstTopFuncLayout->addWidget(backButton);
    grid->addWidget(firstTopFuncWidget);
    ////////////////////////////////////////////////////////////////////////////
    QWidget *topFuncWidget = new QWidget(function);
    QHBoxLayout *topFuncLayout = new QHBoxLayout(topFuncWidget);

    m_iconLabel = new QLabel(topFuncWidget);
    m_iconLabel->setPixmap(QPixmap(":/image/lb_warning").scaled(180, 180));
    m_iconLabel->setFixedSize(210, 180);
    ////////////////////////////////////////////////////////////////////////////

    QWidget *topLineWidget = new QWidget(topFuncWidget);
    QVBoxLayout *topLineLayout = new QVBoxLayout(topLineWidget);
    topLineLayout->setContentsMargins(10, 5, 5, 0);
    QLabel *nameLabel = new QLabel(topLineWidget);
    QFont nameFont = nameLabel->font();
    nameFont.setPixelSize(20);
    nameLabel->setFont(nameFont);
    nameLabel->setStyleSheet(MusicUIObject::MFontStyle01);
    nameLabel->setText("-");
    QLabel *singerLabel = new QLabel(topLineWidget);
    singerLabel->setStyleSheet(MusicUIObject::MColorStyle04 + MusicUIObject::MFontStyle03);
    singerLabel->setText("-");
    QLabel *playCountLabel = new QLabel(topLineWidget);
    playCountLabel->setStyleSheet(MusicUIObject::MColorStyle04 + MusicUIObject::MFontStyle03);
    QLabel *updateTimeLabel = new QLabel(topLineWidget);
    updateTimeLabel->setStyleSheet(MusicUIObject::MColorStyle04 + MusicUIObject::MFontStyle03);
    updateTimeLabel->setText("-");

    topLineLayout->addWidget(nameLabel);
    topLineLayout->addWidget(singerLabel);
    topLineLayout->addWidget(playCountLabel);
    topLineLayout->addWidget(updateTimeLabel);
    topLineWidget->setLayout(topLineLayout);

    topFuncLayout->addWidget(m_iconLabel);
    topFuncLayout->addWidget(topLineWidget);
    topFuncWidget->setLayout(topFuncLayout);
    grid->addWidget(topFuncWidget);
    ////////////////////////////////////////////////////////////////////////////

    QWidget *functionWidget = new QWidget(this);
    functionWidget->setStyleSheet(MusicUIObject::MPushButtonStyle03);
    QHBoxLayout *hlayout = new QHBoxLayout(functionWidget);
    m_songButton = new QPushButton(functionWidget);
    m_songButton->setText(tr("songItems"));
    m_songButton->setFixedSize(100, 25);
    m_songButton->setCursor(QCursor(Qt::PointingHandCursor));
    hlayout->addWidget(m_songButton);
    hlayout->addStretch(1);
    functionWidget->setLayout(hlayout);
    QButtonGroup *group = new QButtonGroup(this);
    group->addButton(m_songButton, 0);
    connect(group, SIGNAL(buttonClicked(int)), m_container, SLOT(setCurrentIndex(int)));

#ifdef Q_OS_UNIX
    m_songButton->setFocusPolicy(Qt::NoFocus);
#endif
    grid->addWidget(functionWidget);
    //////////////////////////////////////////////////////////////////////
    grid->addWidget(m_container);
    grid->addStretch(1);

    function->setLayout(grid);
    m_mainWindow->layout()->addWidget(function);

    m_resizeWidgets << nameLabel << singerLabel << playCountLabel << updateTimeLabel;
}
void JabberCreateAccountWidget::createGui(bool showButtons)
{
	QVBoxLayout *mainLayout = new QVBoxLayout(this);

	QWidget *formWidget = new QWidget(this);
	mainLayout->addWidget(formWidget);

	QFormLayout *layout = new QFormLayout(formWidget);

	QWidget *jidWidget = new QWidget(this);
	QGridLayout *jidLayout = new QGridLayout(jidWidget);
	jidLayout->setSpacing(0);
	jidLayout->setMargin(0);
	jidLayout->setColumnStretch(0, 2);
	jidLayout->setColumnStretch(2, 2);

	Username = new QLineEdit(this);
	connect(Username, SIGNAL(textEdited(QString)), this, SLOT(dataChanged()));
	jidLayout->addWidget(Username);

	QLabel *atLabel = new QLabel("@", this);
	jidLayout->addWidget(atLabel, 0, 1);

	Domain = new QComboBox();
	Domain->setEditable(true);
	connect(Domain, SIGNAL(currentIndexChanged(QString)), this, SLOT(dataChanged()));
	connect(Domain, SIGNAL(editTextChanged(QString)), this, SLOT(dataChanged()));
	jidLayout->addWidget(Domain, 0, 2);

	layout->addRow(tr("Username") + ':', jidWidget);

	NewPassword = new QLineEdit(this);
	connect(NewPassword, SIGNAL(textEdited(const QString &)), this, SLOT(dataChanged()));
	NewPassword->setEchoMode(QLineEdit::Password);
	layout->addRow(tr("Password") + ':', NewPassword);

	ReNewPassword = new QLineEdit(this);
	connect(ReNewPassword, SIGNAL(textEdited(const QString &)), this, SLOT(dataChanged()));
	ReNewPassword->setEchoMode(QLineEdit::Password);
	layout->addRow(tr("Retype Password") + ':', ReNewPassword);

	RememberPassword = new QCheckBox(tr("Remember password"), this);
	layout->addWidget(RememberPassword);

	IdentityCombo = new IdentitiesComboBox(true, this);
	connect(IdentityCombo, SIGNAL(identityChanged(Identity)), this, SLOT(dataChanged()));
	layout->addRow(tr("Account Identity") + ':', IdentityCombo);

	QLabel *infoLabel = new QLabel(tr("<font size='-1'><i>Select or enter the identity that will be associated with this account.</i></font>"), this);
	infoLabel->setWordWrap(true);
	infoLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
	infoLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
	layout->addRow(0, infoLabel);

	QLabel *moreOptionsLabel = new QLabel;
	moreOptionsLabel->setText(tr("More options:"));

	ExpandConnectionOptionsButton = new QPushButton(">");
	ExpandConnectionOptionsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	connect(ExpandConnectionOptionsButton, SIGNAL(clicked()), this, SLOT(connectionOptionsChanged()));

	QWidget *moreOptions = new QWidget;
	QHBoxLayout *moreOptionsLayout = new QHBoxLayout(moreOptions);
	moreOptionsLayout->addWidget(moreOptionsLabel);
	moreOptionsLayout->addWidget(ExpandConnectionOptionsButton);
	moreOptionsLayout->setAlignment(ExpandConnectionOptionsButton, Qt::AlignLeft);
	moreOptionsLayout->insertStretch(-1);
	moreOptions->setLayout(moreOptionsLayout);

	mainLayout->addWidget(moreOptions);

	OptionsWidget = new QWidget(this);
	QHBoxLayout *optionsLayout = new QHBoxLayout((OptionsWidget));
	QGroupBox *connectionOptions = new QGroupBox(OptionsWidget);
	optionsLayout->addWidget(connectionOptions);
	connectionOptions->setTitle(tr("Connection settings"));

	QVBoxLayout *vboxLayout2 = new QVBoxLayout(connectionOptions);
	vboxLayout2->setSpacing(6);
	vboxLayout2->setMargin(9);

	CustomHostPort = new QCheckBox(connectionOptions);
	CustomHostPort->setText(tr("Manually Specify Server Host/Port") + ':');
	vboxLayout2->addWidget(CustomHostPort);
	connect(CustomHostPort, SIGNAL(toggled(bool)), SLOT(hostToggled(bool)));

	HostPortLayout = new QHBoxLayout();
	HostPortLayout->setSpacing(6);
	HostPortLayout->setMargin(0);

	CustomHostLabel = new QLabel(connectionOptions);
	CustomHostLabel->setText(tr("Host") + ':');
	HostPortLayout->addWidget(CustomHostLabel);

	CustomHost = new QLineEdit(connectionOptions);
	HostPortLayout->addWidget(CustomHost);

	CustomPortLabel = new QLabel(connectionOptions);
	CustomPortLabel->setText(tr("Port") + ':');
	HostPortLayout->addWidget(CustomPortLabel);

	CustomPort = new QLineEdit(connectionOptions);
	CustomPort->setMinimumSize(QSize(56, 0));
	CustomPort->setMaximumSize(QSize(56, 32767));
	CustomPort->setText(QString::number(port_));
	HostPortLayout->addWidget(CustomPort);

	vboxLayout2->addLayout(HostPortLayout);

	QHBoxLayout *EncryptionLayout = new QHBoxLayout();
	EncryptionLayout->setSpacing(6);
	EncryptionLayout->setMargin(0);
	EncryptionModeLabel = new QLabel(connectionOptions);
	EncryptionModeLabel->setText(tr("Encrypt connection") + ':');
	EncryptionLayout->addWidget(EncryptionModeLabel);

	EncryptionMode = new QComboBox(connectionOptions);
	EncryptionMode->addItem(tr("Always"), 0);
	EncryptionMode->addItem(tr("When available"), 1);
	EncryptionMode->addItem(tr("Legacy SSL"), 2);
	connect(EncryptionMode, SIGNAL(activated(int)), SLOT(sslActivated(int)));
	EncryptionLayout->addWidget(EncryptionMode);

	QSpacerItem *spacerItem = new QSpacerItem(151, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
	EncryptionLayout->addItem(spacerItem);
	vboxLayout2->addLayout(EncryptionLayout);

	LegacySSLProbe = new QCheckBox(connectionOptions);
	LegacySSLProbe->setText(tr("Probe legacy SSL port"));
	vboxLayout2->addWidget(LegacySSLProbe);

	mainLayout->addWidget(OptionsWidget);

	mainLayout->addStretch(100);

	QDialogButtonBox *buttons = new QDialogButtonBox(Qt::Horizontal, this);
	mainLayout->addWidget(buttons);

	RegisterAccountButton = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogApplyButton), tr("Register Account"), this);
	QPushButton *cancelButton = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogCancelButton), tr("Cancel"), this);

	buttons->addButton(RegisterAccountButton, QDialogButtonBox::ApplyRole);
	buttons->addButton(cancelButton, QDialogButtonBox::RejectRole);

	connect(RegisterAccountButton, SIGNAL(clicked(bool)), this, SLOT(apply()));
	connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(cancel()));

	if (!showButtons)
		buttons->hide();
}
VBoxDbgConsole::VBoxDbgConsole(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent/* = NULL*/)
    : VBoxDbgBaseWindow(a_pDbgGui, a_pParent), m_pOutput(NULL), m_pInput(NULL), m_fInputRestoreFocus(false),
    m_pszInputBuf(NULL), m_cbInputBuf(0), m_cbInputBufAlloc(0),
    m_pszOutputBuf(NULL), m_cbOutputBuf(0), m_cbOutputBufAlloc(0),
    m_pTimer(NULL), m_fUpdatePending(false), m_Thread(NIL_RTTHREAD), m_EventSem(NIL_RTSEMEVENT),
    m_fTerminate(false), m_fThreadTerminated(false)
{
    setWindowTitle("VBoxDbg - Console");

    /*
     * Create the output text box.
     */
    m_pOutput = new VBoxDbgConsoleOutput(this);

    /* try figure a suitable size */
    QLabel *pLabel = new QLabel(      "11111111111111111111111111111111111111111111111111111111111111111111111111111112222222222", this);
    pLabel->setFont(m_pOutput->font());
    QSize Size = pLabel->sizeHint();
    delete pLabel;
    Size.setWidth((int)(Size.width() * 1.10));
    Size.setHeight(Size.width() / 2);
    resize(Size);

    /*
     * Create the input combo box (with a label).
     */
    QHBoxLayout *pLayout = new QHBoxLayout();
    //pLayout->setSizeConstraint(QLayout::SetMaximumSize);

    pLabel = new QLabel(" Command ");
    pLayout->addWidget(pLabel);
    pLabel->setMaximumSize(pLabel->sizeHint());
    pLabel->setAlignment(Qt::AlignCenter);

    m_pInput = new VBoxDbgConsoleInput(NULL);
    pLayout->addWidget(m_pInput);
    m_pInput->setDuplicatesEnabled(false);
    connect(m_pInput, SIGNAL(commandSubmitted(const QString &)), this, SLOT(commandSubmitted(const QString &)));

# if 0//def Q_WS_MAC
    pLabel = new QLabel("  ");
    pLayout->addWidget(pLabel);
    pLabel->setMaximumSize(20, m_pInput->sizeHint().height() + 6);
    pLabel->setMinimumSize(20, m_pInput->sizeHint().height() + 6);
# endif

    QWidget *pHBox = new QWidget(this);
    pHBox->setLayout(pLayout);

    m_pInput->setEnabled(false);    /* (we'll get a ready notification) */


    /*
     * Vertical layout box on the whole widget.
     */
    QVBoxLayout *pVLayout = new QVBoxLayout();
    pVLayout->setContentsMargins(0, 0, 0, 0);
    pVLayout->setSpacing(5);
    pVLayout->addWidget(m_pOutput);
    pVLayout->addWidget(pHBox);
    setLayout(pVLayout);

    /*
     * The tab order is from input to output, not the other way around as it is by default.
     */
    setTabOrder(m_pInput, m_pOutput);
    m_fInputRestoreFocus = true; /* hack */

    /*
     * Setup the timer.
     */
    m_pTimer = new QTimer(this);
    connect(m_pTimer, SIGNAL(timeout()), SLOT(updateOutput()));

    /*
     * Init the backend structure.
     */
    m_Back.Core.pfnInput   = backInput;
    m_Back.Core.pfnRead    = backRead;
    m_Back.Core.pfnWrite   = backWrite;
    m_Back.Core.pfnSetReady = backSetReady;
    m_Back.pSelf = this;

    /*
     * Create the critical section, the event semaphore and the debug console thread.
     */
    int rc = RTCritSectInit(&m_Lock);
    AssertRC(rc);

    rc = RTSemEventCreate(&m_EventSem);
    AssertRC(rc);

    rc = RTThreadCreate(&m_Thread, backThread, this, 0, RTTHREADTYPE_DEBUGGER, RTTHREADFLAGS_WAITABLE, "VBoxDbgC");
    AssertRC(rc);
    if (RT_FAILURE(rc))
        m_Thread = NIL_RTTHREAD;

    /*
     * Shortcuts.
     */
    m_pFocusToInput = new QAction("", this);
    m_pFocusToInput->setShortcut(QKeySequence("Ctrl+L"));
    addAction(m_pFocusToInput);
    connect(m_pFocusToInput, SIGNAL(triggered(bool)), this, SLOT(actFocusToInput()));

    m_pFocusToOutput = new QAction("", this);
    m_pFocusToOutput->setShortcut(QKeySequence("Ctrl+O"));
    addAction(m_pFocusToOutput);
    connect(m_pFocusToOutput, SIGNAL(triggered(bool)), this, SLOT(actFocusToOutput()));

    addAction(m_pOutput->m_pBlackOnWhiteAction);
    addAction(m_pOutput->m_pGreenOnBlackAction);
    addAction(m_pOutput->m_pCourierFontAction);
    addAction(m_pOutput->m_pMonospaceFontAction);
}
Esempio n. 17
0
Thesaurus::Thesaurus()
{
    m_standAlone = false;
    m_thesProc = new KProcess;
    m_wnProc = new KProcess;

    m_dialog = new KDialog(0);
    m_dialog->setButtons(KDialog::Help | KDialog::Ok | KDialog::Cancel);
    m_dialog->setDefaultButton(KDialog::Ok);
    m_dialog->setHelp(QString(), "thesaurus");
    m_dialog->resize(600, 400);

    KConfigGroup cfg = KGlobal::config()->group("");
    m_dataFile = cfg.readEntry("datafile");
    if (m_dataFile.isEmpty())
        m_dataFile = KGlobal::dirs()->findResource("data", "calligra/thesaurus/thesaurus.txt");
    setCaption();

    m_noMatch = i18n("(No match)");

    m_historyPos = 1;
    QWidget *page = new QWidget();
    m_dialog->setMainWidget(page);
    QVBoxLayout *topLayout = new QVBoxLayout(page);

    QHBoxLayout *row1 = new QHBoxLayout;
    topLayout->addLayout(row1);
    m_edit = new KHistoryComboBox(page);
    QLabel editLabel(i18n("&Search for:"), page);
    editLabel.setBuddy(m_edit);

    m_search = new KPushButton(i18n("S&earch"), page);
    connect(m_search, SIGNAL(clicked()), this, SLOT(slotFindTerm()));
    row1->addWidget(&editLabel, 0);
    row1->addWidget(m_edit, 1);
    row1->addWidget(m_search, 0);
    m_back = new QToolButton(page);
    m_back->setIcon(koIcon("go-previous"));
    m_back->setToolTip(i18nc("@action:button Go back to the previous word in history", "Back"));
    row1->addWidget(m_back, 0);
    m_forward = new QToolButton(page);
    m_forward->setIcon(koIcon("go-next"));
    m_forward->setToolTip(i18nc("@action:button Go forward to the next word in history", "Forward"));
    row1->addWidget(m_forward, 0);

    KPushButton *lang = new KPushButton(i18n("Change Language..."), page);
    connect(lang, SIGNAL(clicked()), this, SLOT(slotChangeLanguage()));
    row1->addWidget(lang, 0);

    connect(m_back, SIGNAL(clicked()), this, SLOT(slotBack()));
    connect(m_forward, SIGNAL(clicked()), this, SLOT(slotForward()));

    m_tabWidget = new KTabWidget(page);
    topLayout->addWidget(m_tabWidget);

    //
    // Thesaurus Tab
    //
    QWidget *thesWidget = new QWidget(m_tabWidget);
    m_tabWidget->addTab(thesWidget, i18n("&Thesaurus"));
    QHBoxLayout *thesLayout = new QHBoxLayout;
    thesWidget->setLayout(thesLayout);

    QGroupBox *synGroupBox = new QGroupBox(i18n("Synonyms"), thesWidget);
    QHBoxLayout *synLayout = new QHBoxLayout();
    synGroupBox->setLayout(synLayout);
    m_synListWidget = new QListWidget(synGroupBox);
    synLayout->addWidget(m_synListWidget);
    thesLayout->addWidget(synGroupBox);

    QGroupBox *hyperGroupBox = new QGroupBox(i18n("More General Words"), thesWidget);
    QHBoxLayout *hyperLayout = new QHBoxLayout();
    hyperGroupBox->setLayout(hyperLayout);
    m_hyperListWidget = new QListWidget(hyperGroupBox);
    hyperLayout->addWidget(m_hyperListWidget);
    thesLayout->addWidget(hyperGroupBox);

    QGroupBox *hypoGroupBox = new QGroupBox(i18n("More Specific Words"), thesWidget);
    QHBoxLayout *hypoLayout = new QHBoxLayout();
    hypoGroupBox->setLayout(hypoLayout);
    m_hypoListWidget = new QListWidget(hypoGroupBox);
    hypoLayout->addWidget(m_hypoListWidget);
    thesLayout->addWidget(hypoGroupBox);

    // single click -- keep display unambiguous by removing other selections:

    connect(m_synListWidget, SIGNAL(itemClicked(QListWidgetItem *)),
            this, SLOT(slotSetReplaceTermSyn(QListWidgetItem *)));
    connect(m_hyperListWidget, SIGNAL(itemClicked(QListWidgetItem *)),
            this, SLOT(slotSetReplaceTermHyper(QListWidgetItem *)));
    connect(m_hypoListWidget, SIGNAL(itemClicked(QListWidgetItem *)),
            this, SLOT(slotSetReplaceTermHypo(QListWidgetItem *)));

    // double click -- set the double clicked item as the new search term

    connect(m_synListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
            this, SLOT(slotFindTermFromList(QListWidgetItem *)));
    connect(m_hyperListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
            this, SLOT(slotFindTermFromList(QListWidgetItem *)));
    connect(m_hypoListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
            this, SLOT(slotFindTermFromList(QListWidgetItem *)));

    //
    // WordNet Tab
    //

    QWidget *wnWidget = new QWidget(m_tabWidget);
    m_tabWidget->addTab(wnWidget, i18n("&Wordnet"));
    QVBoxLayout *wnLayout = new QVBoxLayout;
    wnWidget->setLayout(wnLayout);

    m_wnComboBox = new KComboBox(wnWidget);
    m_wnComboBox->setEditable(false);
    wnLayout->addWidget(m_wnComboBox);
    connect(m_wnComboBox, SIGNAL(activated(int)), this, SLOT(slotFindTerm()));

    m_resultTextBrowser = new KTextBrowser(wnWidget);
    m_resultTextBrowser->setReadOnly(true);
    connect(m_resultTextBrowser, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(slotFindTermFromUrl(const QUrl &)));
    wnLayout->addWidget(m_resultTextBrowser);

    // Connect for the history box
    m_edit->setTrapReturnKey(true);        // Do not use Return as default key...
    connect(m_edit, SIGNAL(returnPressed()), this, SLOT(slotFindTerm()));
    connect(m_edit, SIGNAL(activated(int)), this, SLOT(slotGotoHistory(int)));

    QHBoxLayout *row2 = new QHBoxLayout( /*m_top_layout*/ );
    topLayout->addLayout(row2);
    m_replaceLineEdit = new KLineEdit(page);
    m_replaceLabel = new QLabel(i18n("&Replace with:"), page);
    m_replaceLabel->setBuddy(m_replaceLineEdit);
    row2->addWidget(m_replaceLabel, 0);
    row2->addWidget(m_replaceLineEdit, 1);

    // Set focus
    m_edit->setFocus();
    updateNavButtons();

    connect(m_dialog, SIGNAL(accepted()), this, SLOT(process()));
    connect(m_dialog, SIGNAL(rejected()), this, SLOT(dialogClosed()));
}
Esempio n. 18
0
QWidget* QmitkPropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option
  , const QModelIndex &index) const
{
  QVariant data = index.data(Qt::EditRole);
  QVariant displayData = index.data(Qt::DisplayRole);
  QString name = index.model()->data(index.model()->index(index.row(), index.column()-1)).value<QString>();

  if(data.isValid())
  {

    QWidget* editorWidget = NULL;

    if(data.type() == QVariant::Color)
    {
      QPushButton* colorBtn = new QPushButton(parent);
      QColor color = data.value<QColor>();

      QColor result = QColorDialog::getColor(color);
      if(result.isValid())
      {
        QPalette palette = colorBtn->palette();
        palette.setColor(QPalette::Button, result);
        colorBtn->setPalette(palette);
        colorBtn->setStyleSheet(QString("background-color: %1;foreground-color: %1; border-style: none;").arg(result.name()));
        //colorBtn->setFlat(true);
      }
      // QColorDialog closed by 'Cancel' button, use the old property color
      else
      {
        QPalette palette = colorBtn->palette();
        palette.setColor(QPalette::Button, color);
        colorBtn->setPalette(palette);
        colorBtn->setStyleSheet(QString("background-color: %1;foreground-color: %1; border-style: none;").arg(color.name()));

      }

      connect(colorBtn, SIGNAL(pressed()), this, SLOT(commitAndCloseEditor()));

      editorWidget = colorBtn;
    }

/*
    else if(data.type() == QVariant::Bool)
    {
      QCheckBox *visibilityCheckBox = new QCheckBox(parent);
      connect(visibilityCheckBox, SIGNAL(editingFinished()),
        this, SLOT(commitAndCloseEditor()));

      return visibilityCheckBox;
    }*/


    else if(data.type() == QVariant::Int)
    {
      QSpinBox* spinBox = new QSpinBox(parent);
      spinBox->setSingleStep(1);
      spinBox->setMinimum(std::numeric_limits<int>::min());
      spinBox->setMaximum(std::numeric_limits<int>::max());
      editorWidget = spinBox;
    }
    // see qt documentation. cast is correct, it would be obsolete if we
    // store doubles
    else if(static_cast<QMetaType::Type>(data.type()) == QMetaType::Float)
    {
      QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent);
      spinBox->setDecimals(2);
      spinBox->setSingleStep(0.1);
      if(name == "opacity")
      {
        spinBox->setMinimum(0.0);
        spinBox->setMaximum(1.0);
      }
      else
      {
        spinBox->setMinimum(std::numeric_limits<float>::min());
        spinBox->setMaximum(std::numeric_limits<float>::max());
      }

      editorWidget = spinBox;
    }

    else if(data.type() == QVariant::StringList)
    {
      QStringList entries = data.value<QStringList>();
      QComboBox* comboBox = new QComboBox(parent);
      comboBox->setEditable(false);
      comboBox->addItems(entries);

      editorWidget = comboBox;
    }


    else
    {
      editorWidget = QStyledItemDelegate::createEditor(parent, option, index);
    }

    if ( editorWidget )
    {
      // install event filter
      editorWidget->installEventFilter( const_cast<QmitkPropertyDelegate*>(this) );
    }

    return editorWidget;

  }
  else
    return new QLabel(displayData.toString(), parent);

}
Esempio n. 19
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);
}
Esempio n. 20
0
GLDMaskBox::GLDMaskBox(GLDMaskBoxParam & oTipBoxParam, QWidget *parent)
    : QWidget(parent)
    , m_labelIco(nullptr)
    , m_labelTextTitle(nullptr)
    , m_labelTextBody(nullptr)
    , m_timerClose(nullptr)
    , m_btnClose(nullptr)
    , m_animFadeOut(nullptr)
    , m_effectOpacity(nullptr)
{
    m_oTipBoxParam = oTipBoxParam;

    if (nullptr != oTipBoxParam.m_wgtOwner)
    {
        connect(oTipBoxParam.m_wgtOwner, SIGNAL(clicked()), this, SLOT(slotClose()));
    }

    this->setObjectName(QString("GLDMaskBox"));

    if (m_oTipBoxParam.m_wgtOwner)
    {
        this->setParent(m_oTipBoxParam.m_wgtOwner);
    }

    this->setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip);
    this->setAttribute(Qt::WA_TranslucentBackground);

    QVBoxLayout * layoutMain = new QVBoxLayout();
    layoutMain->setContentsMargins(12, 11, 8, 14);
    this->setLayout(layoutMain);

    QHBoxLayout* layoutToolBar = new QHBoxLayout();
    layoutMain->addLayout(layoutToolBar);
    //layoutToolBar->addWidget(new QWidget(this), 1);

    m_btnClose = new QPushButton(this);
    m_btnClose->setFlat(true);
    connect(m_btnClose, &QPushButton::clicked, this, &GLDMaskBox::slotClose);

    layoutToolBar->addStretch();
    layoutToolBar->addWidget(m_btnClose);
    //layoutToolBar->addWidget(m_btnClose, 0);

    QHBoxLayout * layoutContent = new QHBoxLayout();
    layoutMain->addSpacing(-9);
    layoutMain->addLayout(layoutContent);

    QVBoxLayout * layoutLeft = new QVBoxLayout();
    m_labelIco = new QLabel(this);

    layoutLeft->addSpacing(6);
    layoutLeft->addWidget(m_labelIco);
    layoutLeft->addStretch();
    layoutLeft->addSpacing(18);

//     layoutLeft->addWidget(m_labelIco);
//     layoutLeft->addWidget(new QWidget(this));

    QVBoxLayout * layoutRight = new QVBoxLayout();
    m_labelTextTitle = new QLabel(this);
    m_labelTextTitle->setHidden(true);
    m_labelTextTitle->setOpenExternalLinks(true);
    m_labelTextTitle->setWordWrap(true);
    m_labelTextTitle->setAlignment(Qt::AlignTop);
    layoutRight->addWidget(m_labelTextTitle);

    m_labelTextBody = new QLabel(this);
    m_labelTextBody->setOpenExternalLinks(true);
    m_labelTextBody->setFont(m_oTipBoxParam.m_fontBody);
    //m_labelTextBody->setWordWrap(true);
    //m_labelTextBody->setAlignment(Qt::AlignTop);

    QPalette pa;
    pa.setColor(QPalette::WindowText, m_oTipBoxParam.m_clrBody);
    m_labelTextBody->setPalette(pa);
    m_labelTextBody->setWordWrap(true);
    m_labelTextBody->setAlignment(Qt::AlignTop);

    layoutRight->addWidget(m_labelTextBody);

    layoutContent->addSpacing(21);
    layoutContent->addLayout(layoutLeft, 0);
    layoutContent->addLayout(layoutRight, 1);
    layoutContent->addSpacing(21);
//     layoutContent->addLayout(layoutLeft, 0);
//     layoutContent->addLayout(layoutRight, 1);

    //this->setContentsMargins(10, 5, 10, 15);

    // 关闭定时器设置
    m_timerClose = new QTimer(this);
    connect(m_timerClose, SIGNAL(timeout()), this, SLOT(slotCloseTimer()));

    // 渐隐效果动画设置
    m_effectOpacity = new QGraphicsOpacityEffect(this);
    this->setGraphicsEffect(m_effectOpacity);
    m_effectOpacity->setOpacity(1);
    m_animFadeOut = new QPropertyAnimation(m_effectOpacity, "opacity", this);
    m_animFadeOut->setStartValue(1);
    m_animFadeOut->setEndValue(0);
    //m_animFadeOut->setDuration(m_oTipBoxParam.m_nTimeFadeOut);
    m_animFadeOut->setEasingCurve(QEasingCurve::Linear);
    connect(m_animFadeOut, SIGNAL(finished()), this, SLOT(slotFadeout()));

    // 安装事件过滤器
    QWidget* wgt = m_oTipBoxParam.m_wgtOwner;
    while (wgt)
    {
        wgt->installEventFilter(this);
        wgt = wgt->parentWidget();
    }
}
Esempio n. 21
0
UrlGeneratorJY::UrlGeneratorJY( QWidget* parent )
	: QDialog(parent)
{
	_txtCodec = QTextCodec::codecForName("Big5-ETen");
	setWindowTitle( _txtCodec->toUnicode("URL 產生器") );
	
	QVBoxLayout* vl = new QVBoxLayout;
    vl->setContentsMargins( 4, 4, 4, 4 );
    vl->setSpacing( 4 );
	/* Location IP */
	QHBoxLayout* hl = new QHBoxLayout;
    hl->setContentsMargins( 2, 2, 2, 2 );
    hl->setSpacing( 2 );
	QLabel* lbl = new QLabel( _txtCodec->toUnicode("位置 IP:"), this );
	lbl->setFixedSize( 75, 22 );
	hl->addWidget( lbl );
	hl->addSpacing( 2 );
	_txtLoc = new QTextEdit( this );
	_txtLoc->setMinimumWidth( 200 );
	_txtLoc->setFixedHeight( 40 );
	hl->addWidget( _txtLoc );
	hl->addStretch();
	vl->addLayout( hl );
	/* Location IP */
    hl = new QHBoxLayout;
    hl->setContentsMargins( 2, 2, 2, 2 );
    hl->setSpacing( 2 );
	lbl = new QLabel( _txtCodec->toUnicode("我的最愛 ID:"), this );
	lbl->setFixedSize( 75, 22 );
	hl->addWidget( lbl );
	hl->addSpacing( 2 );
	_edFav = new QLineEdit( this );
	_edFav->setFixedWidth( 40 );
	hl->addWidget( _edFav );
	hl->addStretch();
	vl->addLayout( hl );
	/* Chart Related */
	QGroupBox* gpBox = new QGroupBox( _txtCodec->toUnicode("[圖樣相關]"), this );
	gpBox->setAlignment( Qt::AlignHCenter );
	QVBoxLayout* vlayout = new QVBoxLayout;
    vlayout->setContentsMargins( 0, 0, 0, 0 );
    vlayout->setSpacing( 2 );
	hl = new QHBoxLayout;
    hl->setContentsMargins( 2, 2, 2, 2 );
    hl->setSpacing( 2 );
	lbl = new QLabel( _txtCodec->toUnicode("類型:"), gpBox );
	lbl->setFixedSize( 75, 22 );
	hl->addWidget( lbl );
	hl->addSpacing( 2 );
	_rbLine = new QRadioButton( _txtCodec->toUnicode("趨勢圖"), gpBox );
	_rbLine->setChecked( true );
	hl->addWidget( _rbLine );
	hl->addSpacing( 2 );
	_rbCol = new QRadioButton( _txtCodec->toUnicode("直方圖"), gpBox );
	hl->addWidget( _rbCol );
	hl->addSpacing( 2 );
	_rbPie = new QRadioButton( _txtCodec->toUnicode("圓餅圖"), gpBox );
	hl->addWidget( _rbPie );
	hl->addSpacing( 2 );
	_rbStack = new QRadioButton( _txtCodec->toUnicode("堆疊圖"), gpBox );
	hl->addWidget( _rbStack );
	hl->addStretch();
	vlayout->addLayout( hl );
	hl = new QHBoxLayout;
    hl->setContentsMargins( 2, 2, 2, 2 );
    hl->setSpacing( 2 );
	lbl = new QLabel( _txtCodec->toUnicode("大小:"), gpBox );
	lbl->setFixedSize( 75, 22 );
	hl->addWidget( lbl );
	hl->addSpacing( 2 );
	lbl = new QLabel( _txtCodec->toUnicode("(寬)"), gpBox );
	lbl->setFixedSize( 20, 22 );
	hl->addWidget( lbl );
	hl->addSpacing( 2 );
	_edWidth = new QLineEdit( this );
	_edWidth->setFixedWidth( 80 );
	_edWidth->setText( "640" );
	hl->addWidget( _edWidth );
	hl->addSpacing( 2 );
	lbl = new QLabel( tr("px"), this );
	lbl->setFixedSize( 20, 22 );
	hl->addWidget( lbl );
	hl->addStretch();
	lbl = new QLabel( _txtCodec->toUnicode("(高)"), gpBox );
	lbl->setFixedSize( 20, 22 );
	hl->addWidget( lbl );
	hl->addSpacing( 2 );
	_edHeight = new QLineEdit( this );
	_edHeight->setFixedWidth( 80 );
	_edHeight->setText( "480" );
	hl->addWidget( _edHeight );
	hl->addSpacing( 2 );
	lbl = new QLabel( tr("px"), this );
	lbl->setFixedSize( 20, 22 );
	hl->addWidget( lbl );
	hl->addStretch();
	vlayout->addLayout( hl );
	gpBox->setLayout( vlayout );
	vl->addWidget( gpBox );
	/* Time Related */
	gpBox = new QGroupBox( _txtCodec->toUnicode("[時間相關]"), this );
	gpBox->setAlignment( Qt::AlignHCenter );
	vlayout = new QVBoxLayout;
    vlayout->setContentsMargins( 0, 0, 0, 0 );
    vlayout->setSpacing( 2 );
    QWidget* twid = new QWidget( this );
	hl = new QHBoxLayout;
    hl->setContentsMargins( 2, 2, 2, 2 );
    hl->setSpacing( 2 );
	lbl = new QLabel( _txtCodec->toUnicode("時間區間:"), twid );
	lbl->setFixedSize( 75, 22 );
	hl->addWidget( lbl );
	hl->addSpacing( 2 );
    _rbMin = new QRadioButton( _txtCodec->toUnicode("分"), twid );
	hl->addWidget( _rbMin );
	hl->addSpacing( 2 );
    _rbHr = new QRadioButton( _txtCodec->toUnicode("時"), twid );
	hl->addWidget( _rbHr );
	hl->addSpacing( 2 );
    _rbDay = new QRadioButton( _txtCodec->toUnicode("日"), twid );
	_rbDay->setChecked( true );
	hl->addWidget( _rbDay );
	hl->addSpacing( 2 );
    _rbWeek = new QRadioButton( _txtCodec->toUnicode("週"), twid );
	hl->addWidget( _rbWeek );
	hl->addSpacing( 2 );
    _rbMon = new QRadioButton( _txtCodec->toUnicode("月"), twid );
	hl->addWidget( _rbMon );
	hl->addSpacing( 2 );
    _rbQtr = new QRadioButton( _txtCodec->toUnicode("季"), twid );
	hl->addWidget( _rbQtr );
	hl->addStretch();
	twid->setLayout( hl );
    vlayout->addWidget( twid );
	twid = new QWidget( this );
	hl = new QHBoxLayout;
    hl->setContentsMargins( 2, 2, 2, 2 );
    hl->setSpacing( 2 );
    _rbDef = new QRadioButton( _txtCodec->toUnicode("固定式"), twid );
	_rbDef->setFixedWidth( 200 );
	_rbDef->setChecked( true );
	connect( _rbDef, SIGNAL(clicked()), this, SLOT(_OnClickedMode()) );
	hl->addWidget( _rbDef );
	hl->addStretch();
    _rbMove = new QRadioButton( _txtCodec->toUnicode("移動式"), twid );
	_rbMove->setFixedWidth( 300 );
	connect( _rbMove, SIGNAL(clicked()), this, SLOT(_OnClickedMode()) );
	hl->addWidget( _rbMove );
	hl->addStretch();
	twid->setLayout( hl );
	vlayout->addWidget( twid );
	/* Group Box: Pre-defined */
	hl = new QHBoxLayout;
    hl->setContentsMargins( 2, 2, 2, 2 );
    hl->setSpacing( 2 );
	_gpDef = new QGroupBox( gpBox );
	_gpDef->setAlignment( Qt::AlignHCenter );
    _gpDef->setFixedWidth( 200 );
	QVBoxLayout* vlgp = new QVBoxLayout;
    vlgp->setContentsMargins( 0, 0, 0, 0 );
    vlgp->setSpacing( 2 );
	QHBoxLayout* hlgp = new QHBoxLayout;
    hlgp->setContentsMargins( 2, 2, 2, 2 );
    hlgp->setSpacing( 2 );
	_dtStart = new QDateTimeEdit( QDateTime::currentDateTime().addDays(-1), _gpDef );
	_dtStart->setDisplayFormat( "yyyy-MM-dd HH:mm:ss" );
	_dtStart->setFixedWidth( 120 );
	hlgp->addWidget( _dtStart );
	hlgp->addSpacing( 2 );
	lbl = new QLabel( _txtCodec->toUnicode("至"), _gpDef );
	lbl->setFixedSize( 20, 22 );
	hlgp->addWidget( lbl );
	hlgp->addStretch();
	vlgp->addLayout( hlgp );
    hlgp = new QHBoxLayout;
    hlgp->setContentsMargins( 2, 2, 2, 2 );
    hlgp->setSpacing( 2 );
	_dtEnd = new QDateTimeEdit( QDateTime::currentDateTime(), _gpDef );
    _dtEnd->setDisplayFormat( "yyyy-MM-dd HH:mm:ss" );
	_dtEnd->setFixedWidth( 120 );
	hlgp->addWidget( _dtEnd );
	hlgp->addStretch();
	vlgp->addLayout( hlgp );
	_gpDef->setLayout( vlgp );
	hl->addWidget( _gpDef );
	hl->addStretch();
	/* Group Box: Moving-Time-Axis */
	_gpMove = new QGroupBox( gpBox );
	_gpMove->setAlignment( Qt::AlignHCenter );
	_gpMove->setFixedWidth( 300 );
	_gpMove->setEnabled( false );
    vlgp = new QVBoxLayout;
    vlgp->setContentsMargins( 0, 0, 0, 0 );
    vlgp->setSpacing( 2 );
	hlgp = new QHBoxLayout;
    hlgp->setContentsMargins( 2, 2, 2, 2 );
    hlgp->setSpacing( 2 );
	lbl = new QLabel( _txtCodec->toUnicode("基準點: 今日起"), _gpMove );
	lbl->setFixedSize( 135, 22 );
	hlgp->addWidget( lbl );
	hlgp->addSpacing( 2 );
    _rbFwd = new QRadioButton( _txtCodec->toUnicode("前"), _gpMove );
	_rbFwd->setChecked( true );
	hlgp->addWidget( _rbFwd );
    hlgp->addSpacing( 2 );
	_rbBack = new QRadioButton( _txtCodec->toUnicode("後"), _gpMove );
	hlgp->addWidget( _rbBack );
	hlgp->addSpacing( 2 );
	_spBase = new QSpinBox( _gpMove );
	hlgp->addWidget( _spBase );
	hlgp->addSpacing( 2 );
	lbl = new QLabel( _txtCodec->toUnicode("日"), _gpMove );
	lbl->setFixedSize( 20, 22 );
	hlgp->addWidget( lbl );
	hlgp->addSpacing( 2 );
	_teBase = new QTimeEdit( _gpMove );
	_teBase->setDisplayFormat( "HH:mm" );
	hlgp->addWidget( _teBase );
	hlgp->addStretch();
	vlgp->addLayout( hlgp );
	hlgp = new QHBoxLayout;
    hlgp->setContentsMargins( 2, 2, 2, 2 );
    hlgp->setSpacing( 2 );
	lbl = new QLabel( _txtCodec->toUnicode("回溯點: 基準點往前"), _gpMove );
	lbl->setFixedSize( 135, 22 );
	hlgp->addWidget( lbl );
	hlgp->addSpacing( 2 );
	_spBack = new QSpinBox( _gpMove );
	hlgp->addWidget( _spBack );
	hlgp->addSpacing( 2 );
	lbl = new QLabel( _txtCodec->toUnicode("日"), _gpMove );
	lbl->setFixedSize( 20, 22 );
	hlgp->addWidget( lbl );
	hlgp->addSpacing( 2 );
	_teBack = new QTimeEdit( _gpMove );
    _teBack->setDisplayFormat( "HH:mm" );
	hlgp->addWidget( _teBack );
	hlgp->addStretch();
	vlgp->addLayout( hlgp );
	_gpMove->setLayout( vlgp );
	hl->addWidget( _gpMove );
	hl->addStretch();
	vlayout->addLayout( hl );
    twid = new QWidget( gpBox );
	hl = new QHBoxLayout;
    hl->setContentsMargins( 2, 2, 2, 2 );
    hl->setSpacing( 2 );
	hl = new QHBoxLayout;
    hl->setContentsMargins( 2, 2, 2, 2 );
    hl->setSpacing( 2 );
	lbl = new QLabel( _txtCodec->toUnicode("更新率:"), gpBox );
	lbl->setFixedSize( 75, 22 );
	hl->addWidget( lbl );
	hl->addSpacing( 2 );
    _rbRefM = new QRadioButton( _txtCodec->toUnicode("分"), gpBox );
	_rbRefM->setChecked( true );
	connect( _rbRefM, SIGNAL(clicked()), this, SLOT(_OnClickedRefresh()) );
	hl->addWidget( _rbRefM );
	hl->addSpacing( 2 );
    _rbRefH = new QRadioButton( _txtCodec->toUnicode("時"), gpBox );
	connect( _rbRefH, SIGNAL(clicked()), this, SLOT(_OnClickedRefresh()) );
	hl->addWidget( _rbRefH );
	hl->addSpacing( 2 );
	_edRefresh = new QLineEdit( gpBox );
	_edRefresh->setFixedWidth( 40 );
	_edRefresh->setText( "10" );
	hl->addWidget( _edRefresh );
	hl->addSpacing( 2 );
	_lblRef = new QLabel( _txtCodec->toUnicode("分"), gpBox );
	_lblRef->setFixedSize( 20, 22 );
	hl->addWidget( _lblRef );
	hl->addStretch();
	twid->setLayout( hl );
	vlayout->addWidget( twid );
	gpBox->setLayout( vlayout );
	vl->addWidget( gpBox );
	_txtUrl = new QTextEdit( this );
	_txtUrl->setReadOnly( true );
	vl->addWidget( _txtUrl );
    QFrame* frmSep = new QFrame( this );
    frmSep->setFrameShape( QFrame::HLine );
    frmSep->setFrameShadow( QFrame::Sunken );
	vl->addWidget( frmSep );

	hl = new QHBoxLayout;
    hl->setContentsMargins( 2, 2, 2, 2 );
    hl->setSpacing( 2 );
	hl->addStretch();
	_btnGen = new QPushButton( _txtCodec->toUnicode("產生 URL"), this );
	_btnGen->setFixedSize( 80, 22 );
	_btnGen->setFocusPolicy( Qt::NoFocus );
	connect( _btnGen, SIGNAL(clicked()), this, SLOT(_OnGen()) );
	hl->addWidget( _btnGen );
	QPushButton* btn = new QPushButton( _txtCodec->toUnicode("關閉"), this );
	btn->setFixedSize( 60, 22 );
	btn->setFocusPolicy( Qt::NoFocus );
	connect( btn, SIGNAL(clicked()), this, SLOT(close()) );
	hl->addWidget( btn );
	vl->addLayout( hl );
	vl->addStretch();
	setLayout( vl );

	resize( 520, 250 );
	setMaximumSize( 750, 250 );
}
Esempio n. 22
0
void GLDMaskBox::showEvent(QShowEvent * event)
{
    G_UNUSED(event);

    if (!m_oTipBoxParam.m_wgtOwner)
    {
        return;
    }

    if (m_oTipBoxParam.m_nMaxWidth > 0)
    {
        this->setMaximumWidth(m_oTipBoxParam.m_nMaxWidth);
    }

    QIcon icon(m_oTipBoxParam.m_strIconClose);

    if (m_oTipBoxParam.m_bIsOverTimeShow)
    {
        m_btnClose->setIcon(icon);
        m_btnClose->setEnabled(true);
    }
    else
    {
        m_btnClose->setEnabled(false);
    }

    //m_btnClose->setIcon(icon);

    m_labelTextTitle->setFont(m_oTipBoxParam.m_fontTitle);
    m_labelTextTitle->setText(m_oTipBoxParam.m_strTitle);

    m_labelTextBody->setFont(m_oTipBoxParam.m_fontBody);
    m_labelTextBody->setText(m_oTipBoxParam.m_strBody);

    //为了设置行高,采用HTML,html换行为 <br/>
    m_oTipBoxParam.m_strBody.replace("\n", "<br/>");
    m_labelTextBody->setText(QString("<p style=\"line-height:%1px\">%2</p>")
        .arg(m_oTipBoxParam.m_nRowHeight).arg(m_oTipBoxParam.m_strBody));

    // 设置根据内容调整气泡提示的大小
    //this->layout()->setSizeConstraint(QLayout::SetFixedSize);
    m_labelTextBody->adjustSize();

    QPixmap pxpIco;
    pxpIco.load(m_oTipBoxParam.m_strIcon);

    if (!m_oTipBoxParam.m_sizeIcon.isEmpty())
    {
        pxpIco = pxpIco.scaled(m_oTipBoxParam.m_sizeIcon.width(), m_oTipBoxParam.m_sizeIcon.height(), Qt::KeepAspectRatio);
    }

    m_labelIco->setPixmap(pxpIco);

    m_animFadeOut->setDuration(m_oTipBoxParam.m_nTimeFadeOut);

    QWidget* wgt = m_oTipBoxParam.m_wgtOwner;
    while (wgt)
    {
        qDebug() << wgt->objectName();
        wgt->installEventFilter(this);
        wgt = wgt->parentWidget();
    }

    if (m_timerClose)
    {
        //m_timerClose->start(m_oTipBoxParam.m_nTimeRemain);
    }
}
MulticastStatisticsDialog::MulticastStatisticsDialog(QWidget &parent, CaptureFile &cf, const char *filter) :
    TapParameterDialog(parent, cf)
{
    setWindowSubtitle(tr("UDP Multicast Streams"));

    // XXX Use recent settings instead
    resize(parent.width() * 4 / 5, parent.height() * 3 / 4);

    tapinfo_ = new mcaststream_tapinfo_t();
    tapinfo_->user_data = this;
    tapinfo_->tap_reset = tapReset;
    tapinfo_->tap_draw = tapDraw;

    QStringList header_names = QStringList()
            << tr("Source Address") << tr("Source Port")
            << tr("Destination Address") << tr("Destination Port")
            << tr("Packets") << tr("Packets/s")
            << tr("Avg BW (bps)") << tr("Max BW (bps)")
            << tr("Max Burst") << tr("Burst Alarms")
            << tr("Max Buffers (B)") << tr("Buffer Alarms");

    statsTreeWidget()->setHeaderLabels(header_names);

    for (int col = 0; col < statsTreeWidget()->columnCount(); col++) {
        if (col == col_src_addr_ || col == col_dst_addr_) continue;
        statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight);
    }

    burst_measurement_interval_le_ = new SyntaxLineEdit(this);
    burst_alarm_threshold_le_ = new SyntaxLineEdit(this);
    buffer_alarm_threshold_le_ = new SyntaxLineEdit(this);
    stream_empty_speed_le_ = new SyntaxLineEdit(this);
    total_empty_speed_le_ = new SyntaxLineEdit(this);

    int filter_layout_idx = verticalLayout()->indexOf(filterLayout()->widget());
    QGridLayout *param_grid = new QGridLayout();
    int one_em = fontMetrics().height();
    verticalLayout()->insertLayout(filter_layout_idx, param_grid);

    // Label | LineEdit | | Label | LineEdit | | Label | LineEdit
    // 0       1         2  3       4         5  6       7
    param_grid->setColumnMinimumWidth(2, one_em * 2);
    param_grid->setColumnStretch(2, 1);
    param_grid->setColumnMinimumWidth(5, one_em * 2);
    param_grid->setColumnStretch(5, 1);
    param_grid->addWidget(new QLabel(tr("Burst measurement interval (ms):")), 0, 0, Qt::AlignRight);
    param_grid->addWidget(burst_measurement_interval_le_, 0, 1);
    param_grid->addWidget(new QLabel(tr("Burst alarm threshold (packets):")), 0, 3, Qt::AlignRight);
    param_grid->addWidget(burst_alarm_threshold_le_, 0, 4);
    param_grid->addWidget(new QLabel(tr("Buffer alarm threshold (B):")), 0, 6, Qt::AlignRight);
    param_grid->addWidget(buffer_alarm_threshold_le_, 0, 7);

    param_grid->addWidget(new QLabel(tr("Stream empty speed (Kb/s:")), 1, 0, Qt::AlignRight);
    param_grid->addWidget(stream_empty_speed_le_, 1, 1);
    param_grid->addWidget(new QLabel(tr("Total empty speed (Kb/s:")), 1, 3, Qt::AlignRight);
    param_grid->addWidget(total_empty_speed_le_, 1, 4);

    burst_measurement_interval_le_->setText(QString::number(mcast_stream_burstint));
    burst_alarm_threshold_le_->setText(QString::number(mcast_stream_trigger));
    buffer_alarm_threshold_le_->setText(QString::number(mcast_stream_bufferalarm));
    stream_empty_speed_le_->setText(QString::number(mcast_stream_emptyspeed));
    total_empty_speed_le_->setText(QString::number(mcast_stream_cumulemptyspeed));

    line_edits_ = QList<QWidget *>()
            << burst_measurement_interval_le_ << burst_alarm_threshold_le_
            << buffer_alarm_threshold_le_ << stream_empty_speed_le_
            << total_empty_speed_le_;

    foreach (QWidget *line_edit, line_edits_) {
        line_edit->setMinimumWidth(one_em * 5);
        connect(line_edit, SIGNAL(textEdited(QString)), this, SLOT(updateWidgets()));
    }
Esempio n. 24
0
DockWnd::DockWnd(DockPlugin *plugin, const char *icon, const char *text)
        : QWidget(NULL, "dock",  WType_TopLevel | WStyle_Customize | WStyle_NoBorder | WStyle_StaysOnTop),
        EventReceiver(LowPriority)
{
#ifndef WIN32
#if !defined(QT_MACOSX_VERSION) && !defined(QT_MAC)
    wharfIcon = NULL;
#endif
#endif
    m_plugin = plugin;
    setMouseTracking(true);
    bNoToggle = false;
    bBlink = false;
    m_state = icon;
    blinkTimer = new QTimer(this);
    connect(blinkTimer, SIGNAL(timeout()), this, SLOT(blink()));
#ifdef WIN32
    m_bBalloon = false;
    hShell = NULL;
    setIcon(icon);
    QWidget::hide();
    gDock = this;
    WM_DOCK = RegisterWindowMessageA("SIM dock");
    if (IsWindowUnicode(winId())){
        oldDockProc = (WNDPROC)SetWindowLongW(winId(), GWL_WNDPROC, (LONG)DockWindowProc);
        OSVERSIONINFOA osvi;
        osvi.dwOSVersionInfoSize = sizeof(osvi);
        GetVersionExA(&osvi);
        if ((osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) && (osvi.dwMajorVersion > 4))
            m_bBalloon = true;
        __NOTIFYICONDATAW notifyIconData;
        if (m_bBalloon){
            memset(&notifyIconData, 0, sizeof(notifyIconData));
            notifyIconData.cbSize = sizeof(notifyIconData);
            notifyIconData.uVersion = NOTIFYICON_VERSION;
            Shell_NotifyIconW(NIM_SETVERSION, (NOTIFYICONDATAW*)&notifyIconData);
        }
        memset(&notifyIconData, 0, sizeof(notifyIconData));
        notifyIconData.cbSize = sizeof(notifyIconData);
        notifyIconData.hIcon = topData()->winIcon;
        notifyIconData.hWnd = winId();
        notifyIconData.uCallbackMessage = WM_DOCK;
        notifyIconData.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
        Shell_NotifyIconW(NIM_ADD, (NOTIFYICONDATAW*)&notifyIconData);
    }else{
        oldDockProc = (WNDPROC)SetWindowLongA(winId(), GWL_WNDPROC, (LONG)DockWindowProc);
        __NOTIFYICONDATAA notifyIconData;
        memset(&notifyIconData, 0, sizeof(notifyIconData));
        notifyIconData.cbSize = sizeof(notifyIconData);
        notifyIconData.hIcon = topData()->winIcon;
        notifyIconData.hWnd = winId();
        notifyIconData.uCallbackMessage = WM_DOCK;
        notifyIconData.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
        Shell_NotifyIconA(NIM_ADD, (NOTIFYICONDATAA*)&notifyIconData);
    }
#else
    setMinimumSize(22, 22);
    resize(22, 22);
#if !defined(QT_MACOSX_VERSION) && !defined(QT_MAC)
    bInit = false;
    inTray = false;
    inNetTray = false;

    Display *dsp = x11Display();
    WId win = winId();

    bool bEnlightenment = false;
    QWidget tmp;
    Atom enlightenment_desktop = XInternAtom(dsp, "ENLIGHTENMENT_DESKTOP", false);
    WId w = tmp.winId();
    Window p, r;
    Window *c;
    unsigned int nc;
    while (XQueryTree(dsp, w, &r, &p, &c, &nc)){
        if (c && nc > 0)
            XFree(c);
        if (! p) {
            log(L_WARN, "No parent");
            break;
        }
        unsigned char *data_ret = NULL;
        Atom type_ret;
        int i_unused;
        unsigned long l_unused;
        if ((XGetWindowProperty(dsp, p, enlightenment_desktop, 0, 1, False, XA_CARDINAL,
                                &type_ret, &i_unused, &l_unused, &l_unused,
                                &data_ret) == Success) && (type_ret == XA_CARDINAL)) {
            if (data_ret)
                XFree(data_ret);
            bEnlightenment = true;
            log(L_DEBUG, "Detect Enlightenment");
            break;
        }
        if (p == r) break;
        w = p;
    }

    if (bEnlightenment){
        bInit = true;
        resize(48, 48);
        setFocusPolicy(NoFocus);
        move(m_plugin->getDockX(), m_plugin->getDockY());
        MWMHints mwm;
        mwm.flags = MWM_HINTS_DECORATIONS;
        mwm.functions = 0;
        mwm.decorations = 0;
        mwm.inputMode = 0;
        mwm.status = 0;
        Atom a = XInternAtom(dsp, "_MOTIF_WM_HINTS", False);
        XChangeProperty(dsp, win, a, a, 32, PropModeReplace,
                        (unsigned char *)&mwm, sizeof(MWMHints) / 4);
        XStoreName(dsp, win, "SIM");
        XClassHint *xch = XAllocClassHint();
        xch->res_name  = (char*)"SIM";
        xch->res_class = (char*)"Epplet";
        XSetClassHint(dsp, win, xch);
        XFree(xch);
        XSetIconName(dsp, win, "SIM");
        unsigned long val = (1 << 0) /* | (1 << 9) */ ;
        a = XInternAtom(dsp, "_WIN_STATE", False);
        XChangeProperty(dsp, win, a, XA_CARDINAL, 32, PropModeReplace,
                        (unsigned char *)&val, 1);
        val = 2;
        a = XInternAtom(dsp, "_WIN_LAYER", False);
        XChangeProperty(dsp, win, a, XA_CARDINAL, 32, PropModeReplace,
                        (unsigned char *)&val, 1);
        val = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 5);
        a = XInternAtom(dsp, "_WIN_HINTS", False);
        XChangeProperty(dsp, win, a, XA_CARDINAL, 32, PropModeReplace,
                        (unsigned char *)&val, 1);
        win_name = "SIM";
        win_version = VERSION;
        win_info = "";
        while (!comms_win)
        {
            ECommsSetup(dsp);
            sleep(1);
        }
        char s[256];
        snprintf(s, sizeof(s), "set clientname %s", win_name);
        ECommsSend(s);
        snprintf(s, sizeof(s), "set version %s", win_version);
        ECommsSend(s);
        snprintf(s, sizeof(s), "set info %s", win_info);
        ECommsSend(s);
        ESYNC;

        set_background_properties(this);

        setIcon(icon);
        show();
        return;
    }

    wharfIcon = new WharfIcon(this);
#endif
    setBackgroundMode(X11ParentRelative);
    setIcon(icon);

#if !defined(QT_MACOSX_VERSION) && !defined(QT_MAC)
    XClassHint classhint;
    classhint.res_name  = (char*)"sim";
    classhint.res_class = (char*)"Wharf";
    XSetClassHint(dsp, win, &classhint);

    Screen *screen = XDefaultScreenOfDisplay(dsp);
    int screen_id = XScreenNumberOfScreen(screen);
    char buf[32];
    snprintf(buf, sizeof(buf), "_NET_SYSTEM_TRAY_S%d", screen_id);
    Atom selection_atom = XInternAtom(dsp, buf, false);
    XGrabServer(dsp);
    Window manager_window = XGetSelectionOwner(dsp, selection_atom);
    if (manager_window != None)
        XSelectInput(dsp, manager_window, StructureNotifyMask);
    XUngrabServer(dsp);
    XFlush(dsp);
    if (manager_window != None){
        inNetTray = true;
        if (!send_message(dsp, manager_window, SYSTEM_TRAY_REQUEST_DOCK, win, 0, 0)){
            inNetTray = false;
        }
    }

    Atom kde_net_system_tray_window_for_atom = XInternAtom(dsp, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", false);

    long data[1];
    data[0] = 0;
    XChangeProperty(dsp, win, kde_net_system_tray_window_for_atom, XA_WINDOW,
                    32, PropModeReplace,
                    (unsigned char*)data, 1);

    XWMHints *hints;
    hints = XGetWMHints(dsp, win);
    hints->initial_state = WithdrawnState;
    hints->icon_x = 0;
    hints->icon_y = 0;
    hints->icon_window = wharfIcon->winId();
    hints->window_group = win;
    hints->flags = WindowGroupHint | IconWindowHint | IconPositionHint | StateHint;
    XSetWMHints(dsp, win, hints);
    XFree( hints );

    Event eArgc(EventArgc);
    int argc = (int)eArgc.process();
    Event eArgv(EventArgv);
    char **argv = (char**)eArgv.process();
    XSetCommand(dsp, win, argv, argc);

    if (!inNetTray){
        move(-21, -21);
        resize(22, 22);
    }
#endif
    show();
#endif
    setTip(text);
    reset();
}
Esempio n. 25
0
bool checkPoint(const QPoint &p, const QWidget *w)
{
    QWidget *atW = QApplication::widgetAt(w->mapToGlobal(p));
    if (!atW) return false;
    return atW->topLevelWidget() == w;
}
Esempio n. 26
0
/*!
  \brief Draw a set of points of a seriesItem.

  When observing an measurement while it is running, new points have to be
  added to an existing seriesItem. drawSeries() can be used to display them avoiding
  a complete redraw of the canvas.

  Setting plot()->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
  will result in faster painting, if the paint engine of the canvas widget
  supports this feature.

  \param seriesItem Item to be painted
  \param from Index of the first point to be painted
  \param to Index of the last point to be painted. If to < 0 the
         series will be painted to its last point.
*/
void QwtPlotDirectPainter::drawSeries(
    QwtPlotSeriesItem *seriesItem, int from, int to )
{
    if ( seriesItem == NULL || seriesItem->plot() == NULL )
        return;

    QWidget *canvas = seriesItem->plot()->canvas();
    const QRect canvasRect = canvas->contentsRect();

    QwtPlotCanvas *plotCanvas = qobject_cast<QwtPlotCanvas *>( canvas );

    if ( plotCanvas && qwtHasBackingStore( plotCanvas ) )
    {
        QPainter painter( const_cast<QPixmap *>( plotCanvas->backingStore() ) );

        if ( d_data->hasClipping )
            painter.setClipRegion( d_data->clipRegion );

        qwtRenderItem( &painter, canvasRect, seriesItem, from, to );

        painter.end();

        if ( testAttribute( QwtPlotDirectPainter::FullRepaint ) )
        {
            plotCanvas->repaint();
            return;
        }
    }

    bool immediatePaint = true;
    if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) )
    {
#if QT_VERSION < 0x050000
        if ( !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) )
#endif
            immediatePaint = false;
    }

    if ( immediatePaint )
    {
        if ( !d_data->painter.isActive() )
        {
            reset();

            d_data->painter.begin( canvas );
            canvas->installEventFilter( this );
        }

        if ( d_data->hasClipping )
        {
            d_data->painter.setClipRegion(
                QRegion( canvasRect ) & d_data->clipRegion );
        }
        else
        {
            if ( !d_data->painter.hasClipping() )
                d_data->painter.setClipRect( canvasRect );
        }

        qwtRenderItem( &d_data->painter, canvasRect, seriesItem, from, to );

        if ( d_data->attributes & QwtPlotDirectPainter::AtomicPainter )
        {
            reset();
        }
        else
        {
            if ( d_data->hasClipping )
                d_data->painter.setClipping( false );
        }
    }
    else
    {
        reset();

        d_data->seriesItem = seriesItem;
        d_data->from = from;
        d_data->to = to;

        QRegion clipRegion = canvasRect;
        if ( d_data->hasClipping )
            clipRegion &= d_data->clipRegion;

        canvas->installEventFilter( this );
        canvas->repaint(clipRegion);
        canvas->removeEventFilter( this );

        d_data->seriesItem = NULL;
    }
}
void QLabelMouseTracking::expandToBottomRight(QMouseEvent *ev)
{
    QWidget *mainWidget = this->parentWidget();
    QRect geo = mainWidget->geometry();
    mainWidget->setGeometry(geo.x(),geo.y(),geo.width() + ev->x(),geo.height() + ev->y());
}
Esempio n. 28
0
/*****************************************************************************
* CameraExample
*/
CameraExample::CameraExample(QWidget *parent) :
    QMainWindow(parent)
{
    setWindowTitle("QCameraExample");

    // Opitimizations for screen update and drawing qwidget
    setAutoFillBackground(false);

    // Prevent to screensaver to activate
    m_systemScreenSaver = new QSystemScreenSaver(this);
    m_systemScreenSaver->setScreenSaverInhibit();

    m_myVideoSurface = 0;
    pictureCaptured = false;
    showViewFinder = false;
    m_focusing = false;

    // MMS handling
    m_message = new Message(this);
    QObject::connect(m_message, SIGNAL(messageStateChanged(int)), this, SLOT(messageStateChanged(int)));
    QObject::connect(m_message, SIGNAL(messageReceived(QString,QString,QPixmap)), this, SLOT(messageReceived(QString,QString,QPixmap)));

    // Business card handling (Contact's avatar picture)
    m_businessCardHandling = new BusinessCardHandling(this);

    // Black background
    QPalette palette = this->palette();
    palette.setColor(QPalette::Background, Qt::black);
    setPalette(palette);

    // Main widget & layout
    QWidget* mainWidget = new QWidget(this);
    mainWidget->setPalette(palette);

    QHBoxLayout* hboxl = new QHBoxLayout;
    hboxl->setSpacing(0);
    hboxl->setMargin(0);

    // UI stack
    m_stackedWidget = new QStackedWidget();
    m_stackedWidget->setPalette(palette);

    // First widget to stack
    m_videoWidget = new QWidget();
    m_videoWidget->setPalette(palette);
    m_stackedWidget->addWidget(m_videoWidget);

    // Second widget to stack
    QWidget* secondWidget = new QWidget(this);
    secondWidget->setPalette(palette);
    m_stackedWidget->addWidget(secondWidget);
    m_stackedWidget->setCurrentIndex(0);

    hboxl->addWidget(m_stackedWidget);

    // Buttons
    QSize iconSize(80, 80);
    QVBoxLayout* vboxl = new QVBoxLayout;
    vboxl->setSpacing(0);
    vboxl->setMargin(0);

    // Exit button
    m_exit = new Button(this);
    QObject::connect(m_exit, SIGNAL(pressed()), qApp, SLOT(quit()));
    QPixmap p = QPixmap(":/icons/exit.png");
    m_exit->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
    vboxl->addWidget(m_exit);
    vboxl->setAlignment(m_exit, Qt::AlignHCenter | Qt::AlignTop);

    // Camera button
    m_cameraBtn = new Button(this);
    QObject::connect(m_cameraBtn, SIGNAL(pressed()), this, SLOT(searchAndLock()));
    p = QPixmap(":/icons/camera.png");
    m_cameraBtn->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
    vboxl->addWidget(m_cameraBtn);
    vboxl->setAlignment(m_cameraBtn, Qt::AlignCenter);

    // Send MMS button
    m_mms = new Button(this);
    QObject::connect(m_mms, SIGNAL(pressed()), this, SLOT(openContactsDlg()));
    p = QPixmap(":/icons/mms.png");
    m_mms->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
    vboxl->addWidget(m_mms);
    vboxl->setAlignment(m_mms, Qt::AlignHCenter | Qt::AlignBottom);
#ifndef MESSAGING_ENABLED
    m_mms->disableBtn(true);
    m_mms->setEnabled(false);
#endif

    hboxl->addLayout(vboxl);
    mainWidget->setLayout(hboxl);

    setCentralWidget(mainWidget);

    // Enable camera after 1s, so that the application is started
    // and widget is created to landscape orientation
    QTimer::singleShot(1000,this,SLOT(enableCamera()));
}
Esempio n. 29
0
Viewport::Viewport(int scale, int autoUpdateInterval, bool openGL, QWidget *parent) : QWidget(parent)
{
	// Init
	this->scale = scale;
	sliderZoom = NULL;
	maps = new QList<Map*>();
	mapMetas = new QList<MapMeta*>();
	antiAlias = true;
	selectedAction = NULL;
	timerAutoUpdate = new QTimer();
	timerAutoUpdate->setInterval(autoUpdateInterval);
	this->setAttribute(Qt::WA_DeleteOnClose, true);
	this->setWindowIcon(QIcon(":eye"));
	this->setWindowTitle("emss Viewport");
	maxMapWidth = 0.0;
	maxMapHeight = 0.0;

	// Toolbar
	this->setLayout(new QVBoxLayout());
	this->layout()->setContentsMargins(0,0,0,0);
	toolbar = new QToolBar();
	toolbar->setAutoFillBackground(true);
	this->layout()->addWidget(toolbar);

	// Add scrollbars...
	gridLayout = new QGridLayout();
	gridLayout->setContentsMargins(0,0,0,0);
	QWidget *gridHolder = new QWidget();
	gridHolder->setLayout(gridLayout);
	this->layout()->addWidget(gridHolder);
	scrollHorizontal = new QScrollBar(Qt::Horizontal);
	scrollHorizontal->setMinimum(0);
	scrollHorizontal->setMaximum(1000);
	scrollHorizontal->setSingleStep(10);
	scrollVertical = new QScrollBar(Qt::Vertical);
	scrollVertical->setMinimum(0);
	scrollVertical->setMaximum(1000);
	scrollVertical->setSingleStep(10);
	gridLayout->addWidget(scrollHorizontal,3,1);
	gridLayout->addWidget(scrollVertical,0,2);

	// Canvas
	if(openGL)	canvas = new DrawCanvasGL();
	else		canvas = new DrawCanvas();
	gridLayout->addWidget(canvas, 0,1);

	// Zoom
	if(openGL) {
		// Only allow zooming if open gl. Software render is just not built for this...
		sliderZoom = new QSlider(Qt::Horizontal);
		setNaturalZoom();
		gridLayout->addWidget(sliderZoom,2,1);
	}

	// Build menu
	menuMain = new QMenu(this);
	QAction *actionLabelNativeOrGL = new QAction( (openGL ? "openGL Render" : "Native Render"), menuMain);
	actionLabelNativeOrGL->setEnabled(false);
	menuMain->addAction(actionLabelNativeOrGL);
	actionAntiAlias = new QAction("Anti Alias", menuMain);
	actionAntiAlias->setCheckable(true);
	actionAntiAlias->setChecked(antiAlias);
	menuMain->addAction(actionAntiAlias);
	actionAutoUpdate = new QAction("Auto Update", menuMain);
	actionAutoUpdate->setCheckable(true);
	actionAutoUpdate->setChecked(true);
	menuMain->addAction(actionAutoUpdate);
	actionAutoFocus = new QAction("Auto Focus", menuMain);
	actionAutoFocus->setCheckable(true);
	actionAutoFocus->setChecked(true);
	menuMain->addAction(actionAutoFocus);
	menuMaps = new QMenu("Maps");
	menuMain->addMenu(menuMaps);

	// Register events
	this->setFocusPolicy(Qt::StrongFocus);
	this->setMouseTracking(true);

	// Connections
	connect(menuMain, SIGNAL(triggered(QAction*)), this, SLOT(menuAction(QAction*)));
	connect(menuMaps, SIGNAL(triggered(QAction*)), this, SLOT(menuAction(QAction*)));
	connect(toolbar, SIGNAL(actionTriggered(QAction*)), this, SLOT(toolbarAction(QAction*)));
	connect(timerAutoUpdate, SIGNAL(timeout()), this, SLOT(paintAndShow()));
	connect(canvas,SIGNAL(draw(QPainter*)), this, SLOT(drawMaps(QPainter*)));
	connect(canvas,SIGNAL(mouseClick(QMouseEvent*)), this, SLOT(canvasClicked(QMouseEvent*)));
	if(sliderZoom) connect(sliderZoom, SIGNAL(valueChanged(int)), this, SLOT(zoomChanged()));

	// Start timers...
	resizeScrollbars();
	timerAutoUpdate->start();
}
Esempio n. 30
0
QWidget * PropertyEditorFactory::createEditorWithParent(AbstractValueProperty & property, QWidget * parent)
{
	QWidget * editor = createEditor(property);
	editor->setParent(parent);
	return editor;
}