Esempio n. 1
0
void BatchJob::ShowLog()
{

    QDialog dlg(MIMainWindow::instance());
    dlg.setWindowTitle(logFile);
    dlg.setModal(true);
    dlg.setSizeGripEnabled(true);
    QVBoxLayout *mainLayout = new QVBoxLayout;
    dlg.setLayout(mainLayout);

    QTextBrowser *browse = new QTextBrowser(&dlg);
    mainLayout->addWidget(browse);

    QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dlg);
    mainLayout->addWidget(bb);
    dlg.connect(bb, SIGNAL(accepted()), &dlg, SLOT(accept()));

    QFile logFileObj(logFile);
    if ( !logFileObj.open(QFile::ReadOnly | QFile::Text) )
    {
        browse->setPlainText(QObject::tr("ERROR: Log file %1 not found!")
                             .arg(logFile));
    }
    else
    {
        QTextStream logStream(&logFileObj);
        browse->setPlainText(logStream.readAll());
    }

    dlg.exec();
}
Esempio n. 2
0
void MainWindow::createOutputTab(const QString &label, const QString &content)
{
  QTextBrowser *browser = new QTextBrowser(m_tabWidget);
  QFont f;
  f.setFamily("monospace");
  browser->setCurrentFont(f);

  m_tabWidget->addTab(browser, label);

  browser->setPlainText(content);
}
Esempio n. 3
0
void Exporter::seePreview()
{
    QTextDocument *document = buildFinalDoc();

    if(dialogMode == "export")
    {

        previewDialog = new QDialog(this);
        previewDialog->setAttribute(Qt::WA_DeleteOnClose);
        previewDialog->setWindowTitle(document->metaInformation(QTextDocument::DocumentTitle));
        previewDialog->setMinimumSize(500,500);

        QVBoxLayout *layout = new QVBoxLayout;


        QTextBrowser *browser = new QTextBrowser;
        if(ui->fileTypeComboBox->currentIndex() == 2){ // if format is txt (plaintext)
            browser->setPlainText(document->toPlainText());
        }
        else{
            browser->setDocument(document);

        }



        QDialogButtonBox *buttons = new QDialogButtonBox((QDialogButtonBox::Ok
                                                          | QDialogButtonBox::Cancel), Qt::Horizontal);
        connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
        connect(buttons, SIGNAL(rejected()), this, SLOT(closePreview()));

        layout->addWidget(browser);
        layout->addWidget(buttons);
        previewDialog->setLayout(layout);
        previewDialog->show();


    }


    if(dialogMode == "print")
    {

        QPrinter printer;

        QPrintPreviewDialog printPreviewDialog(&printer, this, Qt::Dialog);
        connect(&printPreviewDialog, SIGNAL(paintRequested(QPrinter*)), this, SLOT(previewPrint(QPrinter*))) ;
        printPreviewDialog.exec();
    }
Esempio n. 4
0
Window::Window()
{
    QTextBrowser *centralWidget = new QTextBrowser;
    centralWidget->setPlainText(tr("Central widget"));

    BorderLayout *layout = new BorderLayout;
    layout->addWidget(centralWidget, BorderLayout::Center);
    layout->addWidget(createLabel("North"), BorderLayout::North);
    layout->addWidget(createLabel("West"), BorderLayout::West);
    layout->addWidget(createLabel("East 1"), BorderLayout::East);
    layout->addWidget(createLabel("East 2") , BorderLayout::East);
    layout->addWidget(createLabel("South"), BorderLayout::South);
    setLayout(layout);

    setWindowTitle(tr("Border Layout"));
}
Esempio n. 5
0
void FirewallCodeViewer::fileSelected(int idx)
{
    if (pages.contains(idx))
    {
        ui->pages->setCurrentIndex(pages[idx]);
    }
    else
    {
        QFile f(this->files.at(idx));
        f.open(QFile::ReadOnly);
        QTextBrowser *browser = new QTextBrowser(ui->pages);
        browser->setPlainText(f.readAll());
        ui->pages->addWidget(browser);
        pages.insert(idx, ui->pages->indexOf(browser));
        ui->pages->setCurrentWidget(browser);
    }
}
QWidget *PluginAboutPage::createPage(QWidget *parent)
{
    if (!m_Spec)
        return new QWidget(parent);

    QWidget *w = new QWidget(parent);
    QVBoxLayout *layout = new QVBoxLayout(w);
    layout->setSpacing(0);
    layout->setMargin(0);
    QTreeWidget *tree = new QTreeWidget(w);
    tree->header()->hide();
    layout->addWidget(tree);
    QLabel *lbl = new QLabel(w);
    lbl->setText(tkTr(Trans::Constants::DESCRIPTION));
    layout->addWidget(lbl);
    QTextBrowser *tb = new QTextBrowser(w);
    layout->addWidget(tb);

    // popuplate tree
    tree->clear();
    QFont f;
    f.setBold(true);
    QTreeWidgetItem *i = 0;
    i = new QTreeWidgetItem(tree, QStringList() << tkTr(Trans::Constants::INFORMATION));
    i->setFont(0,f);
    new QTreeWidgetItem(i, QStringList() << tkTr(Trans::Constants::VERSION) + " " + m_Spec->version() );
    if (Utils::isDebugWithoutInstallCompilation()) {
        new QTreeWidgetItem( i, QStringList() << tkTr(Trans::Constants::BUILD_DEBUG) + " - no install");
    } else {
        new QTreeWidgetItem( i, QStringList() << tkTr(Trans::Constants::BUILD_RELEASE) );
    }
    new QTreeWidgetItem(i, QStringList() << "License: " + m_Spec->license());
    tree->expandAll();

    // populate textbrowser
    tb->setPlainText(m_Spec->description());

    return w;
}
Esempio n. 7
0
/*!
    Shows the application log.
    \todo Write some sort of log viewer.
*/
void MvdMainWindow::showLog()
{
    QFileInfo fi(paths().logFile());
    QFile file(fi.absoluteFilePath());
    if (!file.open(QIODevice::ReadOnly)) {
        QMessageBox::warning(this, MVD_CAPTION, tr("Failed to open the log file."));
        return;
    }

    QTextBrowser *viewer = new QTextBrowser;
    viewer->setWindowFlags(Qt::Tool);
    viewer->setWindowModality(Qt::NonModal);
    viewer->resize(640, 480);

    new MvdLogSyntaxHighlighter(viewer->document());

    QTextStream stream(&file);
    QString text = stream.readAll();

    viewer->setPlainText(text);
    viewer->show();
}