int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QTextEdit *editor = new QTextEdit;

    QTextDocument *document = new QTextDocument(editor);
    QTextCursor cursor(document);

    QImage image(64, 64, QImage::Format_RGB32);
    image.fill(qRgb(255, 160, 128));

//! [Adding a resource]
    document->addResource(QTextDocument::ImageResource,
        QUrl("mydata://image.png"), QVariant(image));
//! [Adding a resource]

//! [Inserting an image with a cursor]
    QTextImageFormat imageFormat;
    imageFormat.setName("mydata://image.png");
    cursor.insertImage(imageFormat);
//! [Inserting an image with a cursor]

    cursor.insertBlock();
    cursor.insertText("Code less. Create more.");

    editor->setDocument(document);
    editor->setWindowTitle(tr("Text Document Images"));
    editor->resize(320, 480);
    editor->show();

//! [Inserting an image using HTML]
    editor->append("<img src=\"mydata://image.png\" />");
//! [Inserting an image using HTML]

    return app.exec();
}
示例#2
0
//слот - создание нового корабля
void MyServer::slotNewShip(){

    deleteShipButton->setEnabled(false);

    //создание корабля
    ShipItemStruct* ship = new ShipItemStruct;
    ship->isNew=1;
    shipList.append(ship);

    //если это первый корабль
    if(!shipCounter){
        QTextEdit *txt = (QTextEdit*) txtStack->widget(0);
        txt->append("Ship created");


        //shipCounter++;
        timer->start(500); // TIMER
    }

    //если не первый корабль
    else{
        //создаем новый лог
        QTextEdit *txt = new QTextEdit;
        txt->setReadOnly(true);
        txt->append("Ship created");

        txtStack->addWidget(txt);
        nextButton->setEnabled(true);
    }
    shipCounter++;
}
示例#3
0
//отправление данных по всем кораблям
void MyServer::sendAllData(){
    //deleteShipButton->setEnabled(false);

    QByteArray block;
    QDataStream out (&block, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_5_5);

    out << quint16(0) << logNumbersOfRemovedShips.size();       //количество удаленных кораблей
    for(int k = 0; k < logNumbersOfRemovedShips.size(); k++){   //номер лога удаленного корабля
        out << logNumbersOfRemovedShips.at(k);                  //
    }

    logNumbersOfRemovedShips.clear();

    out << shipCounter;     //количество существующих на сервере кораблей

    //для всех кораблей
    for(int i=0; i < shipCounter; i++){

        generateData(shipList.at(i));   //генерируем новые данные

        out << shipList.at(i)->id
            << shipList.at(i)->startX
            << shipList.at(i)->startY
            << shipList.at(i)->courseAngle
            << shipList.at(i)->speed
            << shipList.at(i)->viewAngle
            << shipList.at(i)->viewLength
            << shipList.at(i)->pathLength
            << shipList.at(i)->time;



        QTextEdit *te = (QTextEdit*)txtStack->widget(i);        //получение указателя на лог текущего корабля
        te->append(QString("Id: %1").arg(shipList.at(i)->id+1));//вывод сгенерированной информации в лог

        if(shipList.at(i)->isNew){
            te->append(QString("Start X: %1\nStart Y: %2")
                       .arg(shipList.at(i)->startX)
                       .arg(shipList.at(i)->startY));
        }



        te->append(QString("Course angle: %1 deg\nSpeed: %2\nView angle: %3 deg\nViewLength: %4\nPath length: %5 m\nTime: %6 sec\n")
                       .arg(shipList.at(i)->courseAngle)
                       .arg(shipList.at(i)->speed).arg(shipList.at(i)->viewAngle)
                       .arg(shipList.at(i)->viewLength).arg(shipList.at(i)->pathLength).arg(shipList.at(i)->time/1000.0f));

        shipList.at(i)->isNew=0;
    }

    out.device()->seek(0);  //переход в начало блока
    out<<quint16(block.size()-sizeof(quint16)); //размер блока данных
    if(isClientConnected) socket->write(block);   //посылка клиенту, если он подключен
    block.clear();          //очистка используемого блока

    if(!deleteShipButton->isEnabled()&& shipCounter>0) deleteShipButton->setEnabled(true);
}
void
CSAVE_WORKSHEET::
saveWorksheet(QTabWidget * tabWidget)
{
    QTextEdit * textEdit = new QTextEdit();
    QString fileName = QFileDialog::getSaveFileName(this,tr("Save PM Worksheet"), "",tr("PM Worksheet (*.pmw);;All Files (*)"));
    textEdit->clear();
    textEdit->hide();

    if (fileName.isEmpty())
            return;
    else
    {
        QFile file(fileName);
        QTextStream out(&file);

        if (!file.open(QIODevice::WriteOnly))
        {
            QMessageBox::information(this, tr("Unable to open file"),file.errorString());
            return;
        }

        for ( int i = 0; i < tabWidget->count(); i++ )
        {
            tabWidget->setCurrentIndex(i); // set to Master PM
            QTableWidget *table = dynamic_cast<QTableWidget *>(tabWidget->currentWidget()); // get control

            QString itemData;
            textEdit->append("[ SECTION ] "+tabWidget->tabText(i));

            for ( int j = 0; j < table->rowCount(); j++ )
            {
                for ( int k = 0; k < 12; k++ )
                {
                     itemData.append(table->item(j,k)->text()+" | ");
                }

                textEdit->append(itemData.trimmed());
                itemData.clear();
            }

            out << textEdit->toPlainText() << endl;
            textEdit->clear();
        }
    }

    tabWidget->setCurrentIndex(2);
    QMessageBox::information(this, "Information", "\n Saved worksheet successfully.", QMessageBox::Ok);
}
 void flush(void) {
   QTextBlockFormat bf = editor->textCursor().blockFormat();
   bf.setBottomMargin(0);
   editor->textCursor().setBlockFormat(bf);
   editor->append(buffer);
   buffer.clear();        
 }
示例#6
0
void ExplorerPane::updateOutput(const QString& output)
{
    QTextEdit *outputWidget = dynamic_cast<QTextEdit *>(outputPage);
    if (outputWidget)
    {
        // Append the new output
        outputWidget->append(output);
        // Raise the Output tab
        tabWidget->setCurrentWidget(outputPage);
    }
}
示例#7
0
 virtual int overflow(int v = std::char_traits<char>::eof()) {
     if (v == '\n') {
         QTextBlockFormat bf = editor->textCursor().blockFormat();
         bf.setBottomMargin(0);
         editor->textCursor().setBlockFormat(bf);
         editor->append(buffer);
         buffer.clear();
     } else {
         buffer += (char)v;
     }
     return v;
 }
示例#8
0
void NewTransferDlg::addLinks(QString links)
{
	QTextEdit* target;
	target = /*radioDownload->isChecked() ?*/ textURIs /*: textFiles*/;

	QStringList sl = links.split('\n');
	foreach (QString s, sl)
	{
		s = s.trimmed();
		if (!target->toPlainText().contains(s))
			target->append(s);
	}
static QScriptValue myPrintErrFunc(QScriptContext *context, QScriptEngine *engine){
    if (context->argumentCount() < 1)
        return engine->undefinedValue();
    
    QString result = context->argument(0).toString();
    
    for (int i = 1; i < context->argumentCount(); i++)
        result = result.arg(context->argument(i).toString());
   
    QScriptValue calleeData = context->callee().data();
    QTextEdit *textEdit = qobject_cast<QTextEdit*>(calleeData.toQObject());

    if (textEdit)
        textEdit->append(result);

    return engine->undefinedValue();
}
示例#10
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QTabWidget *tab = new QTabWidget;
    QTextEdit *edit = new QTextEdit;
    Widget *w = new Widget;

    tab->addTab(w, "edit");
    tab->addTab(edit, "recv");

    QObject::connect(w, SIGNAL(message(QString)), edit, SLOT(append(QString)));
    edit->append("plain text");
    tab->show();
//    Widget w;
//    w.show();

    return a.exec();
}
PanelDeHerramientas::PanelDeHerramientas(QWidget *parent, const char *name) : QDockWindow(parent, name)
{
	box = new QVBox(this);
	setWidget(box);
	toolBox = new QToolBox (box);
	
	QTabWidget *tab = new QTabWidget;
	tab->addTab(new QWidget, "opcion1");
	tab->addTab(new QWidget, "opcion2");
	tab->addTab(new QWidget, "opcion2");
	toolBox->addItem(tab, "Opciones");
	
	QTextEdit *te = new QTextEdit(this);
	te->append("ESTE ES EL TEXTO1");
	toolBox->addItem(te, "Editor" );
	QTextEdit *te2 = new QTextEdit(this);
	te2->append("ESTE ES EL TEXTO2");
	toolBox->addItem(te2, "Editor2" );
}
示例#12
0
int main (int argc, char * argv[])
{
	QStringList lineList;
	QString curLine;
	Dictionary myDict(argv[2]);

  	QApplication myApp(argc, argv);
   	QTextEdit wid;
 	wid.setMinimumSize(500,300);
 	wid.setAcceptRichText(true);
  	QString word;
  	QTextStream stream(&word);
	
	QFile myFile(argv[1]);
	myFile.open(QIODevice::ReadOnly);
	QTextStream inFile(&myFile);

	while(!inFile.atEnd())
	{
		curLine = inFile.readLine();					//file is read
		lineList = curLine.split(QRegExp("\\b"), QString::SkipEmptyParts);	//the string is split into parts
		for (int c = 0; c < lineList.size(); c++)
		{
			if (myDict.dictLook(lineList[c]) == 0)			//if the word was misspelled, then
			{
				stream << "<font color=red>";			//red font tags are placed around the word
				stream << lineList[c];
				stream << "</font>";
			}
			else
			{
				stream << lineList[c];				//otherwise they are just outputted
			}
		}
		wid.append(word);						//printed to text editor
		word = "";							//string cleared
	
	}
 	wid.show();
	return myApp.exec();
}
示例#13
0
void Gui::privateMessage(const QString &receiver, const QString &message)
{
#ifdef DEBUG
	qDebug() << "You got the private message";
#endif
	QTextEdit* outputArea = NULL;
	bool isNeededTab = false;
	for (int i = 0; i < _tabs->count(); ++i)
		if (_tabs->tabText(i) == receiver) 
		{
			_outputAreas.at(i)->append(receiver + ": " + message);
			isNeededTab = true;
			break;
		}
	if (isNeededTab) return;
	outputArea = new QTextEdit;
	outputArea->setReadOnly(true);
	_tabs->addTab(outputArea, receiver);
	_outputAreas.append(outputArea);
	outputArea->setGeometry(0,0,395,230);
	outputArea->append(receiver + ": " + message);
}
示例#14
0
void ExplorerPane::updateErrors(const QString& errors)
{
    QTextEdit *errorWidget = dynamic_cast<QTextEdit *>(errorsPage);
    if (errorWidget)
    {
        // Get the current text
        QString text = errorWidget->toPlainText();
        if (!text.isEmpty())
        {
            // Set the text color to light grey
            errorWidget->setTextColor(QColor("grey"));
            // Restore the current text
            errorWidget->setPlainText(text);
        }
        // Set the text color to red
        errorWidget->setTextColor(QColor("red"));
        // Append the new error message
        errorWidget->append(errors);
        // Place cursor at end of text
        errorWidget->moveCursor(QTextCursor::End);
        // Raise the Error tab
        tabWidget->setCurrentWidget(errorsPage);
    }
}
示例#15
0
void MainWindow::on_actionAbout_triggered()
{
	QTextEdit *pTxt = new QTextEdit(this);
	pTxt->setWindowFlags(Qt::Window); //or Qt::Tool, Qt::Dialog if you like
	pTxt->setReadOnly(true);
	pTxt->append("LhaTool by Ilkka Prusi 2011");
	pTxt->append("");
	pTxt->append("This program is free to use and distribute. No warranties of any kind.");
	pTxt->append("Program uses Qt 4.7.2 under LGPL v. 2.1");
	pTxt->append("");
	pTxt->append("Keyboard shortcuts:");
	pTxt->append("F = open LHa-file");
	pTxt->append("X = eXtract all to..");
	pTxt->append("T = Test extraction");
	pTxt->append("C = codec");
	pTxt->append("Esc = close");
	pTxt->append("? = about (this dialog)");
	pTxt->append("");
	pTxt->show();
}
示例#16
0
int main(int argc, char *argv[]) {
	QApplication myApp(argc, argv);
	if (argc != 3)
	{
		qDebug() << "Error: invalid usage. \nUsage: <file> <language>";
		return 1;
	}
	// initialize a widget for outputting the results
	QTextEdit myWidget;
	myWidget.setMinimumSize(500,300);
	myWidget.setAcceptRichText(true);

	// File input variables
	QStringList inWords;
	QString text;

	// Map for missed words
	QMap<QString, int> missedList;

	// Input words from file, get rid of punctuation
	QFile inFile(myApp.arguments()[1]);
	if (inFile.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		QTextStream in(&inFile);
		text = in.readAll();
		inWords = text.split(QRegExp("\\W+"), QString::SkipEmptyParts);
	}
	else
	{
		qDebug() << "Error: File could not be found OR doesn't exist!";
		return 1;
	}

	// if language is american use the american-english dictionary
	if (myApp.arguments()[2] == "american")
	{
		QString file = QString("/usr/share/dict/american-english");
		// initialize the dictionary
		Dictionary myAmericanDict(file);
		// create the misspelled word map
		myAmericanDict.isMisspelled(inWords);
		// output the map
		missedList = myAmericanDict.getMissedWords();
	}
	else if (myApp.arguments()[2] == "british")
	{
		QString file = QString("/usr/share/dict/british-english");
		// initialize the dictionary
		Dictionary myBritishDict(file);
		// create the misspelled word map
		myBritishDict.isMisspelled(inWords);
		// output the map
		missedList = myBritishDict.getMissedWords();
	}
	// if language specified is not an option, output error and exit
	else
	{
		qDebug() << "Error: User specified dictionary not found!";
		return 1;
	}
	// variables for formatting misspelled words
	QString sred = "<font color = '#ff0000'>";
	QString ered = "</font>";
	QString temp;

	// go through the missedspelled words and color the word
	// in text red
	foreach(const QString &str, missedList.keys())
	{
		if (text.contains(str))
		{
			temp = sred+str+ered;
			text.replace(str, temp);
		}
	}
	// append and show the formatted text
	myWidget.append(text);
	myWidget.show();
	return myApp.exec();
	//return 0;
}
示例#17
0
HelixConfigDialogBase::HelixConfigDialogBase( HelixEngine *engine, amaroK::PluginConfig *config, QWidget *p )
     : QTabWidget( p )
     , m_core(0)
     , m_plugin(0)
     , m_codec(0)
     , m_device(0)
     , m_engine( engine )
{
    int row = 0;
    QString currentPage;
    QWidget *parent = 0;
    QGridLayout *grid = 0;
    QScrollView *sv = 0;

    QString pageName( i18n("Main") );

    addTab( sv = new QScrollView, pageName );
    parent = new QWidget( sv->viewport() );

    sv->setResizePolicy( QScrollView::AutoOneFit );
    sv->setHScrollBarMode( QScrollView::AlwaysOff );
    sv->setFrameShape( QFrame::NoFrame );
    sv->addChild( parent );

    grid = new QGridLayout( parent, /*rows*/20, /*cols*/2, /*margin*/10, /*spacing*/10 );
    grid->setColStretch( 0, 1 );
    grid->setColStretch( 1, 1 );

    if( sv )
       sv->setMinimumWidth( grid->sizeHint().width() + 20 );

    engine->m_coredir = HelixConfig::coreDirectory();
    m_core = new HelixConfigEntry( parent, engine->m_coredir, 
                                   config, row, 
                                   i18n("Helix/Realplay core directory"), 
                                   HelixConfig::coreDirectory().utf8(),
                                   i18n("This is the directory where clntcore.so is located"));
    ++row;
    engine->m_pluginsdir = HelixConfig::pluginDirectory();
    m_plugin = new HelixConfigEntry( parent, engine->m_pluginsdir, 
                                     config, row, 
                                     i18n("Helix/Realplay plugins directory"), 
                                     HelixConfig::pluginDirectory().utf8(),
                                     i18n("This is the directory where, for example, vorbisrend.so is located"));
    ++row;
    engine->m_codecsdir = HelixConfig::codecsDirectory();
    m_codec = new HelixConfigEntry( parent, engine->m_codecsdir, 
                                     config, row, 
                                     i18n("Helix/Realplay codecs directory"), 
                                     HelixConfig::codecsDirectory().utf8(),
                                     i18n("This is the directory where, for example, cvt1.so is located"));
    ++row;
    grid->addMultiCellWidget( new KSeparator( KSeparator::Horizontal, parent ), row, row, 0, 1 );

    ++row;
    m_device = new HelixSoundDevice( parent, config, row, engine );

    // lets find the logo if we can
    QPixmap *pm = 0;
    QString logo = HelixConfig::coreDirectory();
    if (logo.isEmpty()) 
       logo = HELIX_LIBS "/common";

    logo.append("/../share/");

    QString tmp = logo;
    tmp.append("hxplay/logo.png");
    if (QFileInfo(tmp).exists())
    {
       logo = tmp;
       pm = new QPixmap(logo);
    }
    else
    {
       tmp = logo;
       tmp.append("realplay/logo.png");
       if (QFileInfo(tmp).exists())
       {
          logo = tmp;
          pm = new QPixmap(logo);
       }
    }

    if (pm)
    {
       QLabel *l = new QLabel(parent);
       l->setPixmap(*pm);
       grid->addMultiCellWidget( l, 20, 20, 1, 1, Qt::AlignRight );
    }

    entries.setAutoDelete( true );

    pageName = i18n("Plugins");

    addTab( sv = new QScrollView, pageName );
    parent = new QWidget( sv->viewport() );

    sv->setResizePolicy( QScrollView::AutoOneFit );
    sv->addChild( parent );

    QTextEdit *le = new QTextEdit( parent );
    if( sv )
       sv->setMinimumWidth( le->sizeHint().width() );

    grid = new QGridLayout( parent, /*rows*/1, /*cols*/1, /*margin*/2, /*spacing*/1 );
    grid->addMultiCellWidget( le, 0, 1, 0, 1, 0 );
    le->setWordWrap(QTextEdit::NoWrap);

    int n = engine->numPlugins();
    const char *description, *copyright, *moreinfourl;
    row = 0;
    for (int i=0; i<n; i++)
    {
       if (!engine->getPluginInfo(i, description, copyright, moreinfourl))
       {
          le->append(QString(description));
          le->append(QString(copyright));
          le->append(QString(moreinfourl));
          le->append(QString(" "));
       }
    }

    le->setReadOnly(true);
    le->setContentsPos(0,0);
}
示例#18
0
文件: pmquery.cpp 项目: DundalkIT/pcp
PmQuery::PmQuery(bool inputflag, bool printflag, bool noframeflag,
		 bool nosliderflag, bool usesliderflag, bool exclusiveflag)
    : QDialog()
{
    QHBoxLayout *hboxLayout;
    QVBoxLayout *vboxLayout;
    QSpacerItem *spacerItem;
    QSpacerItem *spacerItem1;
    QVBoxLayout *vboxLayout1;
    QHBoxLayout *hboxLayout1;
    QSpacerItem *spacerItem2;

    QString filename;
    if (iconic == HOST_ICON)
	filename = tr(":images/dialog-host.png");
    else if (iconic == ERROR_ICON)
	filename = tr(":images/dialog-error.png");
    else if (iconic == WARNING_ICON)
	filename = tr(":images/dialog-warning.png");
    else if (iconic == ARCHIVE_ICON)
	filename = tr(":images/dialog-archive.png");
    else if (iconic == QUESTION_ICON)
	filename = tr(":images/dialog-question.png");
    else // (iconic == INFO_ICON)
	filename = tr(":images/dialog-information.png");

    QIcon	icon(filename);
    QPixmap	pixmap(filename);
    setWindowIcon(icon);
    setWindowTitle(tr(title));

    QGridLayout *gridLayout = new QGridLayout(this);
    gridLayout->setSpacing(6);
    gridLayout->setMargin(9);
    hboxLayout = new QHBoxLayout();
    hboxLayout->setSpacing(6);
    hboxLayout->setMargin(0);
    vboxLayout = new QVBoxLayout();
    vboxLayout->setSpacing(6);
    vboxLayout->setMargin(0);
    spacerItem = new QSpacerItem(20, 2, QSizePolicy::Minimum,
					QSizePolicy::Expanding);

    vboxLayout->addItem(spacerItem);

    QLabel *imageLabel = new QLabel(this);
    imageLabel->setPixmap(pixmap);

    vboxLayout->addWidget(imageLabel);

    spacerItem1 = new QSpacerItem(20, 20, QSizePolicy::Minimum,
					  QSizePolicy::Expanding);

    vboxLayout->addItem(spacerItem1);
    hboxLayout->addLayout(vboxLayout);
    vboxLayout1 = new QVBoxLayout();
    vboxLayout1->setSpacing(6);
    vboxLayout1->setMargin(0);

    int height;
    int width = DEFAULT_EDIT_WIDTH; 

    QLineEdit* lineEdit = NULL;
    QTextEdit* textEdit = NULL;
    if (inputflag && messagecount <= 1) {
	lineEdit = new QLineEdit(this);
	if (messagecount == 1)
	    lineEdit->setText(tr(messages[0]));
	height = lineEdit->font().pointSize() + 4;
	if (height < 0)
	    height = lineEdit->font().pixelSize() + 4;
	if (height < 0)
	    height = lineEdit->heightForWidth(width) + 4;
	lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding,
				QSizePolicy::Fixed);
	lineEdit->setMinimumSize(QSize(width, height));
	lineEdit->setGeometry(QRect(0, 0, width, height));
	vboxLayout1->addWidget(lineEdit);
    }
    else {
	QFont	fixed("monospace");
	fixed.setStyleHint(QFont::TypeWriter);

	textEdit = new QTextEdit(this);
	textEdit->setFont(fixed);
	textEdit->setLineWrapMode(QTextEdit::FixedColumnWidth);
	textEdit->setLineWrapColumnOrWidth(80);
	textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	if (nosliderflag)
	    textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	else if (usesliderflag)
	    textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	else
	    textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	for (int m = 0; m < messagecount; m++)
	    textEdit->append(tr(messages[m]));
	if (inputflag)
	    textEdit->setReadOnly(false);
	else {
	    textEdit->setLineWidth(1);
	    textEdit->setFrameStyle(noframeflag ? QFrame::NoFrame :
				    QFrame::Box | QFrame::Sunken);
	    textEdit->setReadOnly(true);
	}
	if (usesliderflag)
	    height = DEFAULT_EDIT_HEIGHT;
	else {
	    height = textEdit->font().pointSize() + 4;
	    if (height < 0)
		height = textEdit->font().pixelSize() + 4;
	    if (height < 0)
	        height = textEdit->heightForWidth(width) + 4;
	    height *= messagecount;
	}
	textEdit->setMinimumSize(QSize(width, height));
	textEdit->setSizePolicy(QSizePolicy::MinimumExpanding,
				QSizePolicy::MinimumExpanding);
	textEdit->moveCursor(QTextCursor::Start);
	textEdit->ensureCursorVisible();
	vboxLayout1->addWidget(textEdit);
    }

    hboxLayout1 = new QHBoxLayout();
    hboxLayout1->setSpacing(6);
    hboxLayout1->setMargin(0);
    spacerItem2 = new QSpacerItem(40, 20, QSizePolicy::Expanding,
					  QSizePolicy::Minimum);
    hboxLayout1->addItem(spacerItem2);

    for (int i = 0; i < buttoncount; i++) {
	QueryButton *button = new QueryButton(printflag, this);
	button->setMinimumSize(QSize(72, 32));
	button->setDefault(buttons[i] == defaultbutton);
	button->setQuery(this);
	button->setText(tr(buttons[i]));
	button->setStatus(statusi[i]);
	if (inputflag && buttons[i] == defaultbutton) {
	    if (textEdit) 
		button->setEditor(textEdit);
	    else if (lineEdit) {
		button->setEditor(lineEdit);
		if (buttons[i] == defaultbutton)
		    connect(lineEdit, SIGNAL(returnPressed()),
			    button, SLOT(click()));
	    }
	}
	connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
	hboxLayout1->addWidget(button);
    }

    vboxLayout1->addLayout(hboxLayout1);
    hboxLayout->addLayout(vboxLayout1);
    gridLayout->addLayout(hboxLayout, 0, 0, 1, 1);
    gridLayout->setSizeConstraint(QLayout::SetFixedSize);

    if (inputflag && messagecount <= 1)
	resize(QSize(320, 83));
    else
	resize(QSize(320, 132));

    if (timeout)
	startTimer(timeout * 1000);

    if (exclusiveflag)
	setWindowModality(Qt::WindowModal);
}
示例#19
0
bool EmulApp::eventFilter(QObject *watched, QEvent *event)
{
    int type = static_cast<int>(event->type());
    if (type == QEvent::KeyPress) {
    } 
    MainWindow *mw = dynamic_cast<MainWindow *>(watched);
    if (mw) {
        if (type == LogLineEventType) {
            LogLineEvent *evt = dynamic_cast<LogLineEvent *>(event);
            if (evt && mw->textEdit()) {
                QTextEdit *te = mw->textEdit();
                QColor origcolor = te->textColor();
                te->setTextColor(evt->color);
                te->append(evt->str);

                // make sure the log textedit doesn't grow forever
                // so prune old lines when a threshold is hit
                nLinesInLog += evt->str.split("\n").size();
                if (nLinesInLog > nLinesInLogMax) {
                    const int n2del = MAX(nLinesInLogMax/10, nLinesInLog-nLinesInLogMax);
                    QTextCursor cursor = te->textCursor();
                    cursor.movePosition(QTextCursor::Start);
                    for (int i = 0; i < n2del; ++i) {
                        cursor.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor);
                    }
                    cursor.removeSelectedText(); // deletes the lines, leaves a blank line
                    nLinesInLog -= n2del;
                }

                te->setTextColor(origcolor);
                te->moveCursor(QTextCursor::End);
                te->ensureCursorVisible();
                return true;
            } else {
                return false;
            }
        } else if (type == StatusMsgEventType) {
            StatusMsgEvent *evt = dynamic_cast<StatusMsgEvent *>(event);
            if (evt && mw->statusBar()) {
                mw->statusBar()->showMessage(evt->msg, evt->timeout);
                return true;
            } else {
                return false;
            }
        }
    }
    if (watched == this) {
        if (type == QuitEventType) {
            quit();
            return true;
        }
        if (type == SoundTrigEventType) {
            SoundTrigEvent *evt = dynamic_cast<SoundTrigEvent *>(event);
            if (evt) trigSound(evt->trig);
            if (evt->listener) evt->listener->triggered(evt->trig);
            return true;
        }
        if (type == SoundEventType) {
            SoundEvent *evt = dynamic_cast<SoundEvent *>(event);
            if (evt) gotSound(evt->id, evt->name, evt->loops);
            if (evt->listener) evt->listener->gotSound(evt->id);
            return true;
        }
    }
    // otherwise do default action for event which probably means
    // propagate it down
    return QApplication::eventFilter(watched, event);
}
示例#20
0
QTextDocument * Exporter::buildFinalDoc()
{
    //search for checked items :

    QDomDocument domDoc = hub->project()->mainTreeDomDoc();
    QDomElement root = domDoc.documentElement();

    QList<QDomElement> itemList = searchForCheckedItems(root);

    if(itemList.size() == 0)
        return new QTextDocument();


    // set up the progress bar :
    QWidget *progressWidget = new QWidget(this, Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
    QHBoxLayout *progressLayout = new QHBoxLayout(progressWidget);
    QProgressBar *progressBar = new QProgressBar(progressWidget);
    int progressValue = 0;

    progressLayout->addWidget(progressBar);
    progressWidget->setLayout(progressLayout);

    progressBar->setMaximum(itemList.size());
    progressBar->setValue(progressValue);
    progressWidget->show();



    //    QString debug;
    //    qDebug() << "itemList" << debug.setNum(itemList->size());

    QTextDocument *textDocument = new QTextDocument(this);
    QTextEdit *edit = new QTextEdit(this);

    textDocument->setDefaultStyleSheet("p, li { white-space: pre-wrap; } p{line-height: 2em; font-family:'Liberation Serif'; font-size:12pt;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:72px;}");



    for(int i = 0; i < itemList.size(); ++i){
        QDomElement element = itemList.at(i);
        QTextCursor *tCursor = new QTextCursor(textDocument);

        QTextBlockFormat blockFormatLeft;
        blockFormatLeft.setBottomMargin(0);
        blockFormatLeft.setTopMargin(0);
        blockFormatLeft.setTextIndent(72);
        blockFormatLeft.setLineHeight(200, QTextBlockFormat::ProportionalHeight);
        blockFormatLeft.setAlignment(Qt::AlignJustify);
        QTextCharFormat charFormatLeft;
        charFormatLeft.setFontPointSize(12);
        charFormatLeft.setFontFamily("Courrier");

        QTextBlockFormat blockFormatCenter;
        blockFormatCenter.setAlignment(Qt::AlignCenter);


        if(element.tagName() != "separator"){

            qDebug() << "element name : "+ element.attribute("name");
            MainTextDocument *textDoc = hub->project()->findChild<MainTextDocument *>("textDoc_" + element.attribute("number"));
            MainTextDocument *synDoc = hub->project()->findChild<MainTextDocument *>("synDoc_" + element.attribute("number"));
            MainTextDocument *noteDoc = hub->project()->findChild<MainTextDocument *>("noteDoc_" + element.attribute("number"));

            QTextDocumentFragment textFrag(prepareTextDoc(textDoc));
            QTextDocumentFragment synFrag(prepareSynDoc(synDoc));
            QTextDocumentFragment noteFrag(prepareNoteDoc(noteDoc));

            edit->setDocument(textDocument);




            if(element.tagName() == "book"){
                textDocument->setMetaInformation(QTextDocument::DocumentTitle,element.attribute("name", ""));
                edit->append("<h1>" + element.attribute("name", "") + "</h1>");
                tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
                tCursor->mergeBlockFormat(blockFormatCenter);
                edit->append("<h4>" + QDateTime::currentDateTime().toString() + "</h4>");
                tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
                tCursor->mergeBlockFormat(blockFormatCenter);
                edit->append("<br>");
                edit->append("<br>");

            }
            if(element.tagName() == "act"){
                edit->append("<br>");
                edit->append("<br>");
                edit->append("<h2>" + element.attribute("name", "") + "</h2>");
                tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
                tCursor->mergeBlockFormat(blockFormatCenter);
                edit->append("<br>");

            }
            if(element.tagName() == "chapter"){
                edit->append("<br>");
                edit->append("<br>");
                edit->append("<h2>" + element.attribute("name", "") + "</h2>");
                tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
                tCursor->mergeBlockFormat(blockFormatCenter);
                edit->append("<br>");

            }

            if(element.tagName() == "scene" && ui->setSceneTitlesComboBox->currentIndex() != 0){
                QString sceneTitle;
                switch (ui->setSceneTitlesComboBox->currentIndex()){
                case 1:
                    sceneTitle = element.attribute("name", "");
                    break;
                case 2:
                    sceneTitle = "###";
                    break;
                case 3:
                    sceneTitle = "***";
                    break;
                default:
                    sceneTitle = element.attribute("name", "");
                    break;

                }

                edit->append("<br>");
                edit->append("<h3>" + sceneTitle + "</h3>");
                tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
                tCursor->mergeBlockFormat(blockFormatCenter);
                edit->append("<br>");

            }

            if(ui->synopsisCheckBox->isChecked() && !synFrag.isEmpty()){
                edit->append("<br>");
                edit->append("<h4>" + tr("Synopsis") + "</h4>");
                tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
                tCursor->mergeBlockFormat(blockFormatCenter);
                edit->append("<br>");
                tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
                tCursor->insertBlock(blockFormatLeft, charFormatLeft);
                tCursor->insertFragment(synFrag);
            }

            if(ui->notesCheckBox->isChecked() && !noteFrag.isEmpty()){
                edit->append("<br>");
                edit->append("<h4>" + tr("Note") + "</h4>");
                tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
                tCursor->mergeBlockFormat(blockFormatCenter);
                edit->append("<br>");
                tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
                tCursor->insertBlock(blockFormatLeft, charFormatLeft);
                tCursor->insertFragment(noteFrag);
            }

            if(ui->storyCheckBox->isChecked()){
                if((ui->synopsisCheckBox->isChecked() || ui->notesCheckBox->isChecked()) && !textFrag.isEmpty()){
                    tCursor->insertBlock();
                    tCursor->insertHtml("<h4>" + tr("Story") + "</h4>");
                    tCursor->mergeBlockFormat(blockFormatCenter);
                    tCursor->insertBlock();

                }
                tCursor->insertHtml("<br>");
                //                tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
                tCursor->insertBlock(blockFormatLeft, charFormatLeft);
                tCursor->insertFragment(textFrag);
                //                edit->append(textFrag->toHtml());
            }
        }
        else if(element.tagName() == "separator"){
            edit->append("<br>");
            edit->append("<h3>#</h3>");
            tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
            tCursor->mergeBlockFormat(blockFormatCenter);
            edit->append("<br>");
            tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
            tCursor->mergeBlockFormat(blockFormatLeft);
        }




        progressValue += 1;
        progressBar->setValue(progressValue);

    }
    QRegExp reg("-qt-paragraph-type:.*;|margin-top:.*;|margin-bottom:.*;|margin-left:.*;|margin-right:.*;|-qt-block-indent:.*;|text-indent:.*;|font-family:.*;|font-size:.*;");
    reg.setMinimal(true);
    textDocument->setHtml(textDocument->toHtml().remove(reg));

    //find and change final page css style :

    //textDocument->setDefaultStyleSheet("p, li { white-space: pre-wrap; } p{line-height: 2em; font-family:'Liberation Serif'; font-size:14pt;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:72px;}");

    //            <style type="text/css">
    //            p, li { white-space: pre-wrap; }
    //            </style>

    //            tCursor
    //            qDebug() << textDocument->toHtml();


    progressWidget->close();

    return textDocument;
}
示例#21
0
文件: ppplog.cpp 项目: KDE/kppp
void PPPL_ShowLog() {
  QStringList sl, result;

  PPPL_MakeLog(sl);

  bool foundConnect = false;
  bool foundLCP = gpppdata.getPPPDebug();
  QString lcp = QLatin1String("[LCP");
  QString conn = QLatin1String("Connect:");
  QStringList::ConstIterator it = sl.constBegin();
  for( ; it != sl.constEnd(); it++) {
    if((*it).indexOf(lcp) >= 0) {
      foundLCP = true;
      break;
    }
    if((*it).contains(conn))
      foundConnect = true;
  }
  if(foundConnect && !foundLCP) {
    int result = KMessageBox::warningYesNo(0,
				i18n("KPPP could not prepare a PPP log. It is very likely "
				     "that pppd was started without the \"debug\" option.\n"
				     "Without this option it is difficult to find out PPP "
				     "problems, so in general the debug option should be used.\n"
				     "Enable debug now, and restart pppd?"), QString(), KGuiItem(i18n("Restart pppd")), KGuiItem(i18n("Do Not Restart")));

    if(result == KMessageBox::Yes) {
      gpppdata.setPPPDebug(true);
      KMessageBox::information(0,
		       i18n("The \"debug\" option has been added. You "
			    "should now try to reconnect. If that fails "
			    "again, you will get a PPP log that may help "
					"you to track down the connection problem."));
      //      return;
    }

    //    return;
  }

  PPPL_AnalyseLog(sl, result);

  KDialog *dlg = new KDialog();
  dlg->setButtons(KDialog::Close | KDialog::Ok);
  dlg->setWindowTitle(i18n("PPP Log"));
  dlg->setButtonText(KDialog::Ok,i18n("Write to File"));

  KVBox* v = new KVBox(dlg);
  QTextEdit *edit = new QTextEdit(v);
  edit->setReadOnly(true);
  QLabel *label = new QLabel(i18n("kppp's diagnosis (just guessing):"), v);
  QTextEdit *diagnosis = new QTextEdit(v);
  diagnosis->setReadOnly(true);
  edit->setMinimumSize(600, 250);
  label->setMinimumSize(600, 15);
  diagnosis->setMinimumSize(600, 60);

  dlg->setMainWidget(v);

  for(int i = 0; i < sl.count(); i++)
    edit->append(sl.at(i));
  for(int i = 0; i < result.count(); i++)
    diagnosis->append(result.at(i));

  if(dlg->exec()) {
    QDir d = QDir::home();
    QString s = d.absolutePath() + "/PPP-logfile";
    int old_umask = umask(0077);

    FILE *f = fopen(QFile::encodeName(s), "w");
    for(int i = 0; i < sl.count(); i++)
      fprintf(f, "%s\n", sl.at(i).toLocal8Bit().data());
    fclose(f);
    umask(old_umask);

    QString msg = i18n("The PPP log has been saved\nas \"%1\".\n\nIf you want to send a bug report, or have\nproblems connecting to the Internet, please\nattach this file. It will help the maintainers\nto find the bug and to improve KPPP", s);
    KMessageBox::information(0, msg);
  }
  delete dlg;
}
void
CGENERATE_CSTRUCT::
Generate(QTextEdit * textEdit_5, QTextEdit * textEdit_9, QTextEdit * textEdit_13, QTabWidget * tabWidget_3, QString version)
{
    // get MASTER PM tab
    tabWidget_3->setCurrentIndex(3);
    QTableWidget * table = dynamic_cast<QTableWidget *>(tabWidget_3->currentWidget());

    // table rot start and row end
    int start;
    int end;

    for (int sectionEntry = 0; sectionEntry < 3; sectionEntry++)
    {
        QTextEdit * textEdit;               // cstruct

        if ( sectionEntry == 0 )
        {
            start = 0;
            end = 20;
            textEdit = textEdit_5;          // write to it
        }
        else if ( sectionEntry == 1 )
        {
            start = 20;
            end = 41;
            textEdit = textEdit_9;
        }
        else
        {
            start = 41;
            end = table->rowCount();
            textEdit = textEdit_13;
        }

        textEdit->append(version);
        textEdit->append("Copy and paste the struct created below into a C header file.");
        textEdit->append("Total struct byte size = ");
        textEdit->append("\n");

        int x = 0;      // multivalbyte bit accumulator

        for (int j = start; j < end; j++ )
        {
            // update "total struct byte size" with DataLen value
            if ( table->item(j,0)->text().contains("DataLen"))
                textEdit->document()->find("Total struct byte size = ").insertText("Total struct byte size = "+table->item(j,1)->text());

            // multivalbyte first
            QString name = "                                      ";
            QString tmp = table->item(j,0)->text();
            name.replace(0,tmp.length(),tmp);
            QString bitDef = table->item(j,4)->text();   // conversion
            QString bit = table->item(j,7)->text();      // bitsize

            if ( bitDef == "multivalbyte" )
            {
                if ( bit == "1" )
                {
                    textEdit->append("#define _boff_"+name+(QString::number(x)));
                    textEdit->append("#define _bmsk_"+name+"0x1");
                    textEdit->append("");
                    if ( x == 7 )
                        x = 0;
                    else
                        x++;
                }

                else if ( bit == "4" )
                {
                    textEdit->append("#define _boff_"+name+(QString::number(x)));
                    textEdit->append("#define _bmsk_"+name+"0x4");
                    textEdit->append("");
                    if ( x >= 7 )
                        x = 0;
                    else
                        x += 4;
                }

                else
                {
                    textEdit->append("#define _boff_"+name+("0"));
                    textEdit->append("#define _bmsk_"+name+"0xFF");
                    textEdit->append("");
                    x = 0;
                }
            }
        }

        for (int j = start; j < end; j++ )
        {
            if ( j == start )
                textEdit->append("typedef struct {");

            QString Apl8 = "    Apl8";
            QString Apl = "    Apl";
            QString AplR32 = "    AplR32";

            QString name = table->item(j,0)->text();
            QString cell2 = table->item(j,2)->text();              // range
            QString cell4 = table->item(j,4)->text();              // conversion
            QString cell5 = table->item(j,5)->text();              // byteoffset
            int cell7 = table->item(j,7)->text().toInt(0,10);      // bitsize

            if ( cell4 == "multivalbyte" && cell7 == 1 )
            {
                textEdit->append("    Apl8u _byte_"+cell5+";");
                j += 7;
            }

            else if ( cell4 == "multivalbyte" && cell7 != 1 )
                textEdit->append("    Apl8u _byte_"+cell5+";");

            else if ( cell2 == "None" )
                textEdit->append(Apl8+" _"+name+"["+QString::number(cell7/8)+"];");

            else if ( cell4 == "float32" )
                textEdit->append(AplR32+" _"+name+";");

            else if ( cell2.contains("-") )
                textEdit->append(Apl+QString::number(cell7)+" _"+name+";");

            else
                textEdit->append(Apl+QString::number(cell7)+"u"+" _"+name+";");

            if (j == end-1)
                textEdit->append("} PMData_t;\n");

        }

        for (int j = start; j < end; j++ )
        {
            int bitOffset = 0;

            QString name = table->item(j,0)->text();
            QString name2 = table->item(j,0)->text();
            QString name3 = table->item(j,0)->text();

            QString name0 = "                                                "; // size big enough to distance from next column
            name0.replace(0,name2.append("(d)").length(),name2); // to align the space
            QString name1 = "                                                ";
            name1.replace(0,name3.prepend("d._").length(),name3); // to align the space

            QString cell3 = table->item(j,3)->text(); // type
            QString cell4 = table->item(j,4)->text(); // conversion
            QString cell5 = table->item(j,5)->text(); // byte offset
            QString cell6 = table->item(j,6)->text(); // bit offset
            int cell7 = table->item(j,7)->text().toInt(0,10);      // bitsize

            if ( cell4 == "multivalbyte" && cell7 != 1 )
                textEdit->append("#define pm_"+
                                       name0+
                                       " ((((d)._byte_"+
                                       cell5+
                                       ")) & _bmsk_"+
                                       name+
                                       ")"+
                                       "      /* "+
                                       " Type = "+
                                       cell3+
                                       "     Byte Offset = 0x"+
                                       cell5+
                                       "     Bit Offset = "+
                                       cell6+
                                       "     Bit Size = "+
                                       QString::number(cell7)+
                                       "     Conversion = "+
                                       cell4+
                                       " ");

            else if ( cell4 == "multivalbyte" && cell7 == 1)
            {
                if ( name.contains("Bit0") )
                    textEdit->append("#define pm_"+
                                           name0+
                                           " ((((d)._byte_"+
                                           cell5+
                                           ")) & _bmsk_"+
                                           name+
                                           ")"+
                                           "      /* "+
                                           " Type = "+
                                           cell3+
                                           "     Byte Offset = 0x"+
                                           cell5+
                                           "     Bit Offset = "+
                                           cell6+
                                           "     Bit Size = "+
                                           QString::number(cell7)+
                                           "     Conversion = "+
                                           cell4+
                                           " */");

                else
                {
                    //bitOffset++;

                    textEdit->append("#define pm_"+
                                           name0+
                                           " ((((d)._byte_"+
                                           cell5+
                                           ") >> _boff_"+
                                           name+
                                           ") & _bmsk_"+
                                           name+
                                           ")"+
                                           "      /* "+
                                           " Type = "+
                                           cell3+
                                           "     Byte Offset = 0x"+
                                           cell5+
                                           "     Bit Offset = "+
                                           cell6+
                                           //QString::number(bitOffset)+
                                           "     Bit Size = "+
                                           QString::number(cell7)+
                                           "     Conversion = "+
                                           cell4+
                                           " */");
                    //if ( bitOffset == 7 )
                        //bitOffset = 0;
                }
            }

            else
                textEdit->append("#define pm_"+
                                       name0+
                                       name1.prepend(" ")+
                                       "      /*"+
                                       " Type = "+
                                       cell3+
                                       "     Byte Offset = 0x"+
                                       cell5+
                                       "     Bit Offset = 0"+
                                       "     Bit Size = "+
                                       QString::number(cell7)+
                                       "     Conversion = "+
                                       cell4+
                                       " */");
        }
    }
}
示例#23
0
文件: dialog.cpp 项目: pva701/codes
void Dialog::appendToHistory(const QString& name, const QDateTime& sendTime, QTextDocument *document, InsertingMode mode) {
    QListWidgetItem *item = new QListWidgetItem();
    QTextEdit *te = new QTextEdit();
    lwHistory->addItem(item);
    te->setReadOnly(true);
    reloadResource(te);
    lwHistory->setItemWidget(item, te);
    QString color;
    if (name == "You")
        color = "blue";
    else
        color = "red";

    te->append(QString("<font color = \"%1\"> <b>" + name + "</b> (" + sendTime.toString("dd-MM-yyyy hh:mm:ss") + "):</font>").arg(color));
    te->moveCursor(QTextCursor::End);
    te->textCursor().insertBlock();
    te->textCursor().insertFragment(QTextDocumentFragment(document));

    int heig = 17, widthTe = parentWidget()->width();
    int curLine = 0;
    int mx = 0;

    for (QTextBlock bl = te->document()->begin(); bl != te->document()->end(); bl = bl.next())
        if (bl.isValid()) {
            if (bl.begin().atEnd()) {
                heig += 17 + mx;//&&&
                curLine = mx = 0;
                continue;
            }

            for (QTextBlock::iterator it = bl.begin(); !it.atEnd(); ++it) {
                QTextFragment fragm = it.fragment();
                int curw, curh;
                if (fragm.isValid() && fragm.charFormat().isImageFormat()) {
                    curw = smiles->width() / W_CNT;
                    curh = smiles->height() / H_CNT;
                    processCalc(heig, mx, curLine, curw, curh);
                } else if (fragm.isValid()) {
                    QString s = fragm.text();
                    QFontMetrics me(fragm.charFormat().font());
                    curh = me.lineSpacing();
                    for (int j = 0; j < s.size(); ++j) {
                        curw = me.width(s[j]);
                        processCalc(heig, mx, curLine, curw, curh);
                    }
                }
            }
            heig += mx;
            mx = curLine = 0;
        }

    te->setStyleSheet(QString("QFrame {"
                 "border: 2px solid #f3f2f1;"
                 "border-radius: 4px;"
                  "padding: 2px;}"));
    item->setSizeHint(QSize(0, heig + 18));
    te->resize(QSize(widthTe, heig));
    lwHistory->scrollToBottom();

    if (mode == ReceivedMessage && !dgReadByUser) {
        setUnreadMessage(unreadMessage + 1);
        queUnreadWrote.push_back(te);
        te->setStyleSheet("QTextEdit { background-color: #FFFCCC; }");
    } else if (mode == LoadHistory) {

        if (unreadMessage != 0) {
            queUnreadWrote.push_back(te);
            te->setStyleSheet("QTextEdit { background-color: #FFFCCC; }");
            if (queUnreadWrote.size() > unreadMessage) {
                queUnreadWrote.front()->setStyleSheet("QTextEdit { background-color: #FFFFFF; }");
                queUnreadWrote.pop_front();
            }
        }

        if (wroteMessage != 0) {
            queUnreadWrote.push_back(te);
            te->setStyleSheet("QTextEdit { background-color: #DFFFCC; }");
            if (queUnreadWrote.size() > wroteMessage) {
                queUnreadWrote.front()->setStyleSheet("QTextEdit { background-color: #FFFFFF; }");
                queUnreadWrote.pop_front();
            }
        }

    } else if (mode == SendMessage) {
        teMessage->setFocus();
        te->setStyleSheet("QTextEdit { background-color: #DFFFCC; }");
        wroteMessage++;
        queUnreadWrote.push_back(te);
    }
}
示例#24
0
void MainWindow::on_actionHelp_triggered()
{
    // generic help
	
	QTextEdit *pTxt = new QTextEdit(this);
	pTxt->setWindowFlags(Qt::Window); //or Qt::Tool, Qt::Dialog if you like
	pTxt->setReadOnly(true);
	pTxt->append("qPicView by Ilkka Prusi 2011");
	pTxt->append("");
	pTxt->append("This program is free to use and distribute. No warranties of any kind.");
	pTxt->append("Program uses Qt 4.7.1 under LGPL v. 2.1");
	pTxt->append("");
	pTxt->append("Keyboard shortcuts:");
	pTxt->append("");
	pTxt->append("* = resize/fit");
	pTxt->append("+ = zoom in");
	pTxt->append("- = zoom out");
	pTxt->append("Left = previous");
	pTxt->append("Right = next");
	pTxt->append("Up/Down = scroll");
	pTxt->append("");
	pTxt->append("F = open file");
	pTxt->append("F1 = help (this)");
	pTxt->append("F11 = fullscreen toggle");
	pTxt->append("Esc = close");
	pTxt->append("");
	pTxt->append("Tip: set as default program :)");
	pTxt->show();
}
示例#25
0
// -------------------------------------------------------------------------
void ctkQImageView::keyPressEvent( QKeyEvent * event )
{
  Q_D( ctkQImageView );

  if( d->SliceNumber >= 0 && d->SliceNumber < d->ImageList.size() )
    {
    switch( event->key() )
      {
      case Qt::Key_H:
        {
        QTextEdit * help = new QTextEdit();
        help->setWindowFlags( Qt::Window );
        help->setMinimumSize( 500, 500 );
        help->setSizePolicy( QSizePolicy::Preferred,
          QSizePolicy::Preferred );
        help->setReadOnly( true );
        help->append("<h1>CTK Simple Image Viewer Widget</h1>");
        help->append("Contributed by: Kitware, Inc.<br>");
        help->append("<h3>Keyboard commands:</h3>");
        help->append("  <em>q</em> : quit");
        help->append("  <em>h</em> : display this help");
        help->append("  <em>i</em> : invert intensities");
        help->append("  <em>[ ]</em> : increase / decrease zoom");
        help->append("  <em>x y</em> : flip along the x / y axis");
        help->append("  <em>r</em> : reset to initial conditions");
        help->append("  <em>spacebar</em> : toggle continuous tracking of cursor");
        help->append("  <em>up-arrow down-arrow</em> : change to next / previous slice");
        help->append("<h3>Mouse commands:</h3>");
        help->append("  <em>left-button</em> : window and level");
        help->append("  <em>middle-button</em> : zoom");
        help->append("  <em>right-button</em> : center");
        help->show();

        break;
        }
      case Qt::Key_Space:
        {
        d->Window->setMouseTracking( ! d->Window->hasMouseTracking() );
        break;
        }
      case Qt::Key_X:
        {
        this->setFlipXAxis( ! this->flipXAxis() );
        break;
        }
      case Qt::Key_Y:
        {
        this->setFlipYAxis( ! this->flipYAxis() );
        break;
        }
      case Qt::Key_T:
        {
        this->setTransposeXY( ! this->transposeXY() );
        break;
        }
      case Qt::Key_BracketRight:
        {
        this->setZoom( this->zoom() * 1.1 );
        break;
        }
      case Qt::Key_BracketLeft:
        {
        this->setZoom( this->zoom() * 0.9 );
        break;
        }
      case Qt::Key_I:
        {
        this->setInvertImage( ! this->invertImage() );
        this->update( false, false );
        break;
        }
      case Qt::Key_Q:
        {
        exit( EXIT_SUCCESS );
        break;
        }
      case Qt::Key_R:
        {
        this->reset();
        break;
        }
      case Qt::Key_Up:
        {
        this->setSliceNumber( d->SliceNumber+1 );
        break;
        }
      case Qt::Key_Down:
        {
        this->setSliceNumber( d->SliceNumber-1 );
        break;
        }
      default:
        {
        event->ignore();
        }
      };
    }
}