Exemplo n.º 1
0
// Extract the wrapped text from a text edit, which performs
// the wrapping only optically.
void SubmitEditorWidget::wrapDescription()
{
    if (!lineWrap())
        return;
    const QChar newLine = QLatin1Char('\n');
    QTextEdit e;
    e.setVisible(false);
    e.setMinimumWidth(1000);
    e.setFontPointSize(1.0);
    e.setLineWrapColumnOrWidth(d->m_ui.description->lineWrapColumnOrWidth());
    e.setLineWrapMode(d->m_ui.description->lineWrapMode());
    e.setWordWrapMode(d->m_ui.description->wordWrapMode());
    e.setPlainText(d->m_description);
    d->m_description.clear();
    QTextCursor cursor(e.document());
    cursor.movePosition(QTextCursor::Start);
    while (!cursor.atEnd()) {
        const QString block = cursor.block().text();
        if (block.startsWith(QLatin1Char('\t'))) { // Don't wrap
            d->m_description += block + newLine;
            cursor.movePosition(QTextCursor::EndOfBlock);
        } else {
            forever {
                cursor.select(QTextCursor::LineUnderCursor);
                d->m_description += cursor.selectedText();
                d->m_description += newLine;
                cursor.clearSelection();
                if (cursor.atBlockEnd())
                    break;
                cursor.movePosition(QTextCursor::NextCharacter);
            }
        }
        cursor.movePosition(QTextCursor::NextBlock);
    }
}
Exemplo n.º 2
0
QTextEdit* VBoxVMLogViewer::createLogPage (const QString &aName)
{
    QWidget *pageContainer = new QWidget();
    QVBoxLayout *pageLayout = new QVBoxLayout (pageContainer);
    QTextEdit *logViewer = new QTextEdit (pageContainer);
    pageLayout->addWidget (logViewer);
    pageLayout->setContentsMargins (10, 10, 10, 10);

    QFont font = logViewer->currentFont();
    font.setFamily ("Courier New,courier");
    logViewer->setFont (font);
    logViewer->setWordWrapMode (QTextOption::NoWrap);
    logViewer->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
    logViewer->setReadOnly (true);

    mLogList->addTab (pageContainer, aName);
    return logViewer;
}
Exemplo n.º 3
0
void PsiTipLabel::initUi()
{
	margin = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this);
	setFrameStyle(QFrame::NoFrame);

	// doc = new QTextDocument(this);
	// QTextDocumentLayout is private in Qt4
	// and it's impossible to set wrapping mode directly.
	// So we create this QTextEdit instance and use its QTextDocument,
	// just because QTextEdit can set the wrapping mode.
	// Yes, this is crazy...
	QTextEdit *edit = new QTextEdit(this);
	edit->hide();
	edit->setWordWrapMode(QTextOption::WordWrap);
	doc = edit->document();
	doc->setUndoRedoEnabled(false);
	doc->setDefaultFont(font());

	ensurePolished();
	setText(theText_);
}
TrayNotificationWidget::TrayNotificationWidget(QPixmap pixmapIcon, QString headerText, QString messageText) : QWidget(0)
{
    setWindowFlags(
        #ifdef Q_OS_MAC
            Qt::SubWindow | // This type flag is the second point
        #else
            Qt::Tool |
        #endif
            Qt::FramelessWindowHint |
            Qt::WindowSystemMenuHint |
            Qt::WindowStaysOnTopHint
        );
    setAttribute(Qt::WA_NoSystemBackground, true);
    // set the parent widget's background to translucent
    setAttribute(Qt::WA_TranslucentBackground, true);

    //setAttribute(Qt::WA_ShowWithoutActivating, true);

    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    // create a display widget for displaying child widgets
    QWidget* displayWidget = new QWidget;
    displayWidget->setStyleSheet(".QWidget { background-color: rgba(0, 0, 0, 75%); border-width: 1px; border-style: solid; border-radius: 10px; border-color: #555555; } .QWidget:hover { background-color: rgba(68, 68, 68, 75%); border-width: 2px; border-style: solid; border-radius: 10px; border-color: #ffffff; }");

    QLabel* icon = new QLabel;
    icon->setPixmap(pixmapIcon);
    icon->setMaximumSize(32, 32);
    QLabel* header = new QLabel;
    header->setMaximumSize(250, 50);
    header->setWordWrap(true);
    header->setText(headerText);
    header->setStyleSheet("QLabel { color: #ffffff; font-weight: bold; font-size: 12px; }");
    QTextEdit *message = new QTextEdit;
    message->setReadOnly(true);
    message->setFrameStyle(QFrame::NoFrame);
    message->setLineWrapMode(QTextEdit::WidgetWidth);
    message->setWordWrapMode(QTextOption::WrapAnywhere);
    QPalette pal = palette();
    pal.setColor(QPalette::Base, Qt::transparent);
    message->setPalette(pal);
    message->setStyleSheet("QTextEdit { color: #ffffff; font-size: 10px; }");
    message->setText(messageText);
    message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    QVBoxLayout* vl = new QVBoxLayout;
    vl->addWidget(header);
    vl->addWidget(message);

    QHBoxLayout* displayMainLayout = new QHBoxLayout;
    displayMainLayout->addWidget(icon);
    displayMainLayout->addLayout(vl);
    displayWidget->setLayout(displayMainLayout);

    QHBoxLayout* containerLayout = new QHBoxLayout;
    containerLayout->addWidget(displayWidget);
    setLayout(containerLayout);

    show();
    setMinimumHeight((int)(message->document()->size().height() *1.5 + header->height() +70));

    timeout = new QTimer(this);
    connect(timeout, SIGNAL(timeout()), this, SLOT(fadeOut()));
    timeout->start(3000);
}
Exemplo n.º 5
0
AboutDialog::AboutDialog()
: KviTalTabDialog(0)
{
	setWindowTitle(__tr2qs_ctx("About KVIrc...","about"));
	setOkButton(__tr2qs_ctx("Close","about"));

	// About tab
	QString buffer;
	g_pApp->findImage(buffer,"kvi_release_art.png");

	QPixmap pix(buffer);

	QWidget * w = new QWidget(this);
	QGridLayout * g = new QGridLayout(w);

	QLabel * l = new QLabel(w);
	l->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
	QPalette p = l->palette();
	p.setColor(backgroundRole(), Qt::black);
	l->setPalette(p);
	l->setAlignment(Qt::AlignCenter);
	l->setPixmap(pix);

	g->addWidget(l,0,0);

	QString aboutString= "<b>KVIrc " KVI_VERSION " '" KVI_RELEASE_NAME "'</b><br>";
	aboutString += __tr2qs_ctx("Forged by the <b>KVIrc Development Team</b>","about");

	l = new QLabel(aboutString,w);
	l->setAlignment(Qt::AlignCenter);
	g->addWidget(l,1,0);

	addTab(w,__tr2qs_ctx("About","about"));


	// Info tab
	w = new QWidget(this);
	g = new QGridLayout(w);

	QTextEdit * v = new QTextEdit(w);
	v->setReadOnly(true);
	g->addWidget(v,0,0);

	// Get info
	QString infoString = "<b>KVIrc " KVI_VERSION " '" KVI_RELEASE_NAME "'</b><br><br>";
	infoString += "<b>";
	infoString += __tr2qs_ctx("Runtime Info","about");
	infoString += ":</b><br>";
	infoString += __tr2qs_ctx("System name","about");
	infoString += ": ";
	infoString += KviRuntimeInfo::name();
#ifndef COMPILE_ON_MAC
	infoString += " ";
	infoString += KviRuntimeInfo::release();
#endif
	infoString += "<br>";
	infoString += __tr2qs_ctx("System version","about");
	infoString += ": ";
	infoString += KviRuntimeInfo::version();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Architecture","about");
	infoString += ": ";
	infoString += KviRuntimeInfo::machine();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Qt version","about");
	infoString += ": ";
	infoString += KviRuntimeInfo::qtVersion();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Qt theme","about");
	infoString += ": ";
	infoString += KviRuntimeInfo::qtTheme();
	infoString += "<br><br>";
	infoString += "<b>";
	infoString += __tr2qs_ctx("Build Info","about");
	infoString += ":</b><br>";
	infoString += __tr2qs_ctx("Build date","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildDate();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Sources date","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildSourcesDate();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Revision number","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildRevision();
	infoString += "<br>";
	infoString += __tr2qs_ctx("System name","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildSystem();
	infoString += "<br>";
	infoString += __tr2qs_ctx("CPU name","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildCPU();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Build command","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildCommand();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Build flags","about");
	infoString += ": <br>&nbsp;&nbsp;&nbsp;";
	QString flags = KviBuildInfo::buildFlags();
	infoString += flags.replace(QRegExp(";"),"<br>&nbsp;&nbsp;&nbsp;");
	infoString += "<br>";
	infoString += __tr2qs_ctx("Compiler name","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildCompiler();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Compiler flags","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildCompilerFlags();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Qt version","about");
	infoString += ": ";
	infoString += KviBuildInfo::qtVersion();

	v->setText(infoString);

	addTab(w,__tr2qs_ctx("Executable Information","about"));


	// Honor & Glory tab
	w = new QWidget(this);
	g = new QGridLayout(w);

	v = new QTextEdit(w);
	v->setReadOnly(true);
	g->addWidget(v,0,0);

	v->setText(g_szAboutText);

	addTab(w,__tr2qs_ctx("Honor && Glory","about"));


	// License tab
	w = new QWidget(this);
	g = new QGridLayout(w);

	v = new QTextEdit(w);
	v->setReadOnly(true);
	v->setWordWrapMode(QTextOption::NoWrap);
	g->addWidget(v,0,0);

	QString szLicense;

	QString szLicensePath;
	g_pApp->getGlobalKvircDirectory(szLicensePath,KviApplication::License,"COPYING");

	if(!KviFileUtils::loadFile(szLicensePath,szLicense))
	{
		szLicense = __tr2qs_ctx("Oops! Can't find the license file.\n" \
			"It MUST be included in the distribution...\n" \
			"Please report to <pragma at kvirc dot net>","about");
	}

	v->setText(szLicense);

	addTab(w,__tr2qs_ctx("License","about"));


	connect(this,SIGNAL(applyButtonPressed()),this,SLOT(closeButtonPressed()));
}
Exemplo n.º 6
0
void VBoxVMLogViewer::refresh()
{
    /* Clearing old data if any */
    mLogFiles.clear();
    mLogList->setEnabled (true);
    while (mLogList->count())
    {
        QWidget *firstPage = mLogList->widget (0);
        mLogList->removeTab (0);
        delete firstPage;
    }

    bool isAnyLogPresent = false;

    const CSystemProperties &sys = vboxGlobal().virtualBox().GetSystemProperties();
    int cMaxLogs = sys.GetLogHistoryCount();
    for (int i=0; i <= cMaxLogs; ++i)
    {
        /* Query the log file name for index i */
        QString file = mMachine.QueryLogFilename(i);
        if (!file.isEmpty())
        {
            /* Try to read the log file with the index i */
            ULONG uOffset = 0;
            QString text;
            while (true)
            {
                QVector<BYTE> data = mMachine.ReadLog(i, uOffset, _1M);
                if (data.size() == 0)
                    break;
                text.append(QString::fromUtf8((char*)data.data(), data.size()));
                uOffset += data.size();
            }
            /* Anything read at all? */
            if (uOffset > 0)
            {
                /* Create a log viewer page and append the read text to it */
                QTextEdit *logViewer = createLogPage(QFileInfo(file).fileName());
                logViewer->setPlainText(text);
                /* Add the actual file name and the QTextEdit containing the
                   content to a list. */
                mLogFiles << qMakePair(file, logViewer);
                isAnyLogPresent = true;
            }
        }
    }

    /* Create an empty log page if there are no logs at all */
    if (!isAnyLogPresent)
    {
        QTextEdit *dummyLog = createLogPage ("VBox.log");
        dummyLog->setWordWrapMode (QTextOption::WordWrap);
        dummyLog->setHtml (tr ("<p>No log files found. Press the "
            "<b>Refresh</b> button to rescan the log folder "
            "<nobr><b>%1</b></nobr>.</p>")
            .arg (mMachine.GetLogFolder()));
        /* We don't want it to remain white */
        QPalette pal = dummyLog->palette();
        pal.setColor (QPalette::Base, pal.color (QPalette::Window));
        dummyLog->setPalette (pal);
    }

    /* Show the first tab widget's page after the refresh */
    mLogList->setCurrentIndex (0);
    currentLogPageChanged (0);

    /* Enable/Disable save button & tab widget according log presence */
    mBtnFind->setEnabled (isAnyLogPresent);
    mBtnSave->setEnabled (isAnyLogPresent);
    mLogList->setEnabled (isAnyLogPresent);
    /* Default to the save button if there are any log files otherwise to the
     * close button. The initial automatic of the main dialog has to be
     * overwritten */
    setDefaultButton (isAnyLogPresent ? mBtnSave:mBtnClose);
}