Exemplo n.º 1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
  m_sa = new QScrollArea(this);

  setCentralWidget(m_sa);

  QTextEdit *te = new QTextEdit(this);
  te->setMinimumSize(QSize(1000,2000));
  te->setText("very long message\nvery long message\nvery long message\nvery long message\nvery long message\nvery long message\nvery long message\nvery long message\nvery long message\n");
  m_sa->setWidget(te);

}
Exemplo n.º 2
0
void MainDock::help() {
//pd Qt version dependent
#if QT_VERSION >= 0x040200
	QDesktopServices::openUrl(QUrl("Readme.txt"));
#else
	QFile readmeFile("Readme.txt");
	readmeFile.open(QIODevice::ReadOnly);
	QTextStream readmeStream(&readmeFile);
	QString readmeString = readmeStream.readAll();
	//won't close automaticaly
	QTextEdit* readmeTXE = new QTextEdit(0);
	readmeTXE->setMinimumSize(500, 300);
	readmeTXE->setWindowTitle("Parallel Worlds Help");
	readmeTXE->show();
	readmeTXE->setReadOnly(true);
	readmeTXE->setPlainText(readmeString);
#endif
}
MainWindow::MainWindow(const CustomSizeHintMap &customSizeHints,
                       QWidget *parent, Qt::WindowFlags flags)
    : QMainWindow(parent, flags)
{
    setObjectName("MainWindow");
    setWindowTitle("Qt Main Window Example");

    QTextEdit *center = new QTextEdit(this);
    center->setReadOnly(true);
    center->setMinimumSize(400, 205);
    setCentralWidget(center);

    setupToolBar();
    setupMenuBar();
    setupDockWidgets(customSizeHints);

    statusBar()->showMessage(tr("Status Bar"));
}
Exemplo n.º 4
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();
}
Exemplo n.º 5
0
Arquivo: ppplog.cpp Projeto: 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;
}
Exemplo n.º 6
0
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);
}
Exemplo n.º 7
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();
        }
      };
    }
}
Exemplo n.º 8
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;
}