/** Get a message node element, extrapolate its type (public msg, private msg, channelEnter, etc.) and emit the specific signal */ void AJAXChat::emitChatData(const QDomElement &message) { QString messageText = message.firstChildElement("text").text(); // decode html entities from the message text and simplify it QTextEdit t; t.setHtml(messageText); messageText = t.toPlainText().simplified(); if (messageText.startsWith("/")) { QStringList messageParts = messageText.split(" "); if (messageText.startsWith("/privmsg")) { const int userID = message.attribute("userID").toInt(); emit newPrivateMessage(messageParts.at(1), getUser(userID).text()); } else if (messageText.startsWith("/login")) { emit userLoggedIn(messageParts.at(1)); } else if (messageText.startsWith("/logout")) { emit userLoggedOut(messageParts.at(1)); qDebug("Logged out: " + getUser(messageParts.at(1)).text().toUtf8()); } else if (messageText.startsWith("/channelEnter")) { emit userJoinChannel(messageParts.at(1)); } else if (messageText.startsWith("/channelLeave")) { emit userLeaveChannel(messageParts.at(1)); } else if (messageText.startsWith("/kick")) { emit userKicked(messageParts.at(1)); } else if (messageText.startsWith("/nick")) { emit userChangeNick(messageParts.at(1), messageParts.at(2)); } } else { const int userID = message.attribute("userID").toInt(); emit newPublicMessage(messageText, getUser(userID).text()); } }
/** * We get a new Message from a chat participant * * - Ignore Messages from muted chat participants */ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info) { QDateTime sendTime = QDateTime::fromTime_t(info.sendTime); QDateTime recvTime = QDateTime::fromTime_t(info.recvTime); QString message = QString::fromStdWString(info.msg); QString name = QString::fromUtf8(info.peer_nickname.c_str()); QString rsid = QString::fromUtf8(info.rsid.c_str()); std::cerr << "message from rsid " << info.rsid.c_str() << std::endl; if(!isParticipantMuted(name)) { ui.chatWidget->addChatMsg(true, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL); emit messageReceived(id()) ; } // This is a trick to translate HTML into text. QTextEdit editor; editor.setHtml(message); QString notifyMsg = name + ": " + editor.toPlainText(); if(notifyMsg.length() > 30) MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg.left(30) + QString("...")); else MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg); // also update peer list. time_t now = time(NULL); if (now > lastUpdateListTime) { lastUpdateListTime = now; updateParticipantsList(); } }
AboutBox::AboutBox(QWidget* parent) : QDialog(parent) { resize( 500,300); QTextEdit* content = new QTextEdit(); content->setReadOnly(true); QString txt = "<h1>Evilpixie</h1>" "version 0.2<br/><br/>" "By Ben Campbell ([email protected])<br/><br/>" "Licensed under GPLv3<br/>" "Homepage: <a href=\"http://evilpixie.scumways.com\">http://evilpixie.scumways.com</a><br/>" "Source: <a href=\"http://github.com/bcampbell/evilpixie\">http://github.com/bcampbell/evilpixie</a>"; content->setHtml(txt); QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); connect(buttonBox, SIGNAL(accepted()), this, SLOT(hide())); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(content); mainLayout->addWidget(buttonBox); setLayout(mainLayout); setWindowTitle(tr("About EvilPixie")); }
// ---------------------------------------------------------------------- //->setWindowFlags(Qt::Window | Qt::WindowTitleHint); //->setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint); // ---------------------------------------------------------------------- void WxMain::slotActivHelp(){ // QString str = ((QPushButton*)sender())->text(); // if (str == tr("Справка")){ QTextEdit *txt = new QTextEdit; txt->setReadOnly(true); txt->setHtml( tr("<HTML>" "<BODY>" "<H2><CENTER> Справка </CENTER></H2>" "<P ALIGN=\"left\">" "<BR>" "<BR>" "<BR>" "</P>" "<H3><CENTER> Версия 1.2 </CENTER></H3>" "<H4><CENTER> Октябрьь 2013 </CENTER></H4>" "<H4><CENTER> Широков О.Ю. </CENTER></H4>" "<BR>" "</BODY>" "</HTML>" )); txt->resize(250, 200); txt->show(); // "<BODY BGCOLOR=MAGENTA>" // "<FONT COLOR=BLUE>" // "</FONT>" // } // qDebug() << tr("Справка"); return; }// End slot
HelpWindow::HelpWindow() { resize( 600,500); QTextEdit* content = new QTextEdit(); content->setReadOnly(true); { QFile file( JoinPath(g_App->DataPath(), "help.html").c_str() ); if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { QString help_txt; help_txt = file.readAll(); content->setHtml(help_txt); } } QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); connect(buttonBox, SIGNAL(accepted()), this, SLOT(hide())); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(content); mainLayout->addWidget(buttonBox); setLayout(mainLayout); setWindowTitle(tr("Help")); }
void EditStyle::editTextClicked(int id) { QTextEdit* e = 0; switch (id) { case 0: e = evenHeaderL; break; case 1: e = evenHeaderC; break; case 2: e = evenHeaderR; break; case 3: e = oddHeaderL; break; case 4: e = oddHeaderC; break; case 5: e = oddHeaderR; break; case 6: e = evenFooterL; break; case 7: e = evenFooterC; break; case 8: e = evenFooterR; break; case 9: e = oddFooterL; break; case 10: e = oddFooterC; break; case 11: e = oddFooterR; break; } if (e == 0) return; bool styled = id < 6 ? headerStyled->isChecked() : footerStyled->isChecked(); if (styled) e->setPlainText(editPlainText(e->toPlainText(), tr("Edit Plain Text"))); else e->setHtml(editHtml(e->toHtml(), tr("Edit HTML Text"))); }
InfoPanel::InfoPanel(QWidget *parent) :QWidget(parent) { #ifdef K_DEBUG #ifdef Q_OS_WIN qDebug() << "[InfoPanel()]"; #else TINIT; #endif #endif QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom); QLabel *label = new QLabel(tr("Tips")); label->setAlignment(Qt::AlignHCenter); layout->addWidget(label); mainLayout->addLayout(layout); QTextEdit *textArea = new QTextEdit; textArea->setFixedHeight(250); textArea->setHtml("<p><b>" + tr("X Key or Right Mouse Button") + ":</b> " + tr("Close line") + "</p>"); mainLayout->addWidget(textArea); mainLayout->addStretch(2); }
void ClipboardDialog::on_listWidgetFormats_currentItemChanged( QListWidgetItem *current, QListWidgetItem *) { ui->actionRemove_Format->setEnabled(current != NULL); QTextEdit *edit = ui->textEditContent; QString mime = current ? current->text() : QString(); edit->clear(); const QByteArray bytes = m_data.value(mime).toByteArray(); if ( mime.startsWith(QString("image")) ) { edit->document()->addResource( QTextDocument::ImageResource, QUrl("data://1"), bytes ); edit->setHtml( QString("<img src=\"data://1\" />") ); } else { QTextCodec *codec = QTextCodec::codecForName("utf-8"); if (mime == QLatin1String("text/html")) codec = QTextCodec::codecForHtml(bytes, codec); else codec = QTextCodec::codecForUtfText(bytes, codec); edit->setPlainText( codec ? codec->toUnicode(bytes) : QString() ); } ui->labelProperties->setText( tr("<strong> mime:</strong> %1 <strong>size:</strong> %2 bytes") .arg(escapeHtml(mime)) .arg(QString::number(bytes.size()))); }
void dataViewer::addData(QString data) { QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(data)); QTextEdit* sb =new QTextEdit(); sb->setHtml("<h1>Hello <b>World!</b></h1>"); sb->setAutoFillBackground(true); ui.dataTree->setItemWidget(item, 2, sb); currentItem->addChild(item); }
void FriendsDialog::insertChat() { std::list<ChatInfo> newchat; if (!rsMsgs->getPublicChatQueue(newchat)) { #ifdef FRIENDS_DEBUG std::cerr << "no chat available." << std::endl ; #endif return; } #ifdef FRIENDS_DEBUG std::cerr << "got new chat." << std::endl; #endif std::list<ChatInfo>::iterator it; /* add in lines at the bottom */ for(it = newchat.begin(); it != newchat.end(); it++) { /* are they private? */ if (it->chatflags & RS_CHAT_PRIVATE) { /* this should not happen */ continue; } QDateTime sendTime = QDateTime::fromTime_t(it->sendTime); QDateTime recvTime = QDateTime::fromTime_t(it->recvTime); QString name = QString::fromUtf8(rsPeers->getPeerName(it->rsid).c_str()); QString msg = QString::fromStdWString(it->msg); #ifdef FRIENDS_DEBUG std::cerr << "FriendsDialog::insertChat(): " << msg.toStdString() << std::endl; #endif bool incoming = false; // notify with a systray icon msg if(it->rsid != rsPeers->getOwnId()) { incoming = true; // This is a trick to translate HTML into text. QTextEdit editor; editor.setHtml(msg); QString notifyMsg = name + ": " + editor.toPlainText(); if(notifyMsg.length() > 30) emit notifyGroupChat(tr("New group chat"), notifyMsg.left(30) + QString("...")); else emit notifyGroupChat(tr("New group chat"), notifyMsg); } addChatMsg(incoming, false, name, sendTime, recvTime, msg); } }
ZoomConfigurator::ZoomConfigurator(QWidget *parent) :QWidget(parent) { #ifdef K_DEBUG #ifdef Q_OS_WIN32 qDebug() << "[ZoomConfigurator()]"; #else TINIT; #endif #endif QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom); scale = new QLabel(tr("Scale Factor")); scale->setFont(QFont("Arial", 8, QFont::Normal, false)); scale->setAlignment(Qt::AlignHCenter); layout->addWidget(scale); factor = new QDoubleSpinBox(); factor->setDecimals(1); factor->setSingleStep(0.1); factor->setMinimum(0.1); factor->setMaximum(0.9); layout->addWidget(factor); QLabel *label = new QLabel(tr("Tips")); label->setAlignment(Qt::AlignHCenter); label->setFont(QFont("Arial", 8, QFont::Normal, false)); QTextEdit *textArea = new QTextEdit; textArea->setFont(QFont("Arial", 8, QFont::Normal, false)); textArea->setHtml("<p><b>" + tr("Zoom Square mode") + ":</b> " + tr("Press Ctrl key + Mouse left button") + "</p>"); QString text = textArea->document()->toPlainText(); int height = (text.length()*270)/207; textArea->setFixedHeight(height); mainLayout->addLayout(layout); mainLayout->addWidget(label); mainLayout->addWidget(textArea); mainLayout->addStretch(2); TCONFIG->beginGroup("ZoomTool"); double value = TCONFIG->value("zoomFactor", -1).toDouble(); if (value > 0) factor->setValue(value); else factor->setValue(0.5); }
EulaDialog::EulaDialog(QWidget* parent) : QWizard(parent) { setWindowTitle(trEulaTitle); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); //// First page QWizardPage* firstPage = new QWizardPage; QRadioButton* agreeButton = new QRadioButton(trIAgree); VERIFY(connect(agreeButton, &QRadioButton::clicked, this, &EulaDialog::agreeButtonClicked)); QRadioButton* notAgreeButton = new QRadioButton(trIDontAgree); notAgreeButton->setChecked(true); VERIFY(connect(notAgreeButton, &QRadioButton::clicked, this, &EulaDialog::notAgreeButtonClicked)); QHBoxLayout* radioButtonsLay = new QHBoxLayout; radioButtonsLay->setAlignment(Qt::AlignHCenter); radioButtonsLay->setSpacing(30); radioButtonsLay->addWidget(agreeButton); radioButtonsLay->addWidget(notAgreeButton); QTextEdit* textBrowser = new QTextEdit; QFile file(":" PROJECT_NAME_LOWERCASE "/LICENSE"); if (file.open(QFile::ReadOnly | QFile::Text)) { textBrowser->setHtml(file.readAll()); } QVBoxLayout* mainLayout1 = new QVBoxLayout; mainLayout1->addWidget(new QLabel("<h3>" + trEndUserAgr + "</h3>")); mainLayout1->addWidget(textBrowser); mainLayout1->addLayout(radioButtonsLay, Qt::AlignCenter); firstPage->setLayout(mainLayout1); addPage(firstPage); //// Buttons setButtonText(QWizard::CustomButton1, trBack); setButtonText(QWizard::CustomButton2, trNext); setButtonText(QWizard::CustomButton3, trFinish); VERIFY(connect(button(QWizard::CustomButton1), &QAbstractButton::clicked, this, &EulaDialog::backButtonClicked)); VERIFY(connect(button(QWizard::CustomButton2), &QAbstractButton::clicked, this, &EulaDialog::nextButtonClicked)); VERIFY(connect(button(QWizard::CustomButton3), &QAbstractButton::clicked, this, &EulaDialog::finishButtonClicked)); setButtonLayout(QList<WizardButton>{QWizard::Stretch, QWizard::CustomButton1, QWizard::CustomButton2, QWizard::CancelButton, QWizard::CustomButton3}); button(QWizard::CustomButton1)->setHidden(true); button(QWizard::CustomButton2)->setHidden(true); button(QWizard::CustomButton3)->setDisabled(true); setWizardStyle(QWizard::ModernStyle); }
void ItemWidget::setEditorData(QWidget *editor, const QModelIndex &index) const { QTextEdit *textEdit = qobject_cast<QTextEdit *>(editor); if (textEdit != NULL) { if ( index.data(contentType::hasHtml).toBool() ) { const QString html = index.data(contentType::html).toString(); textEdit->setHtml(html); } else { const QString text = index.data(Qt::EditRole).toString(); textEdit->setPlainText(text); } textEdit->selectAll(); } }
int main(int argc, char *argv[]) { QWidget *parent = 0; QString aStringContainingHTMLtext("<h1>Scribe Overview</h1>"); QApplication app(argc, argv); //! [1] QTextEdit *editor = new QTextEdit(parent); editor->setHtml(aStringContainingHTMLtext); editor->show(); //! [1] return app.exec(); }
LicensePage::LicensePage(QWidget *parent) : QWizardPage(parent) { setTitle(tr("License")); QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); QTextEdit *licenseView = new QTextEdit(this); layout->addWidget(licenseView); licenseView->setReadOnly(true); QFile file(":/html/LICENSE.html"); file.open(QFile::ReadOnly); licenseView->setHtml(file.readAll()); file.close(); }
/** * We get a new Message from a chat participant * * - Ignore Messages from muted chat participants */ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) { QDateTime sendTime = QDateTime::fromTime_t(msg.sendTime); QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); QString message = QString::fromUtf8(msg.msg.c_str()); RsGxsId gxs_id = msg.lobby_peer_gxs_id ; if(!isParticipantMuted(gxs_id)) { // We could change addChatMsg to display the peers icon, passing a ChatId RsIdentityDetails details ; QString name ; if(rsIdentity->getIdDetails(gxs_id,details)) name = QString::fromUtf8(details.mNickname.c_str()) ; else name = QString::fromUtf8(msg.peer_alternate_nickname.c_str()) + " (" + QString::fromStdString(gxs_id.toStdString()) + ")" ; ui.chatWidget->addChatMsg(msg.incoming, name, gxs_id, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL); emit messageReceived(msg.incoming, id(), sendTime, name, message) ; SoundManager::play(SOUND_NEW_LOBBY_MESSAGE); // This is a trick to translate HTML into text. QTextEdit editor; editor.setHtml(message); QString notifyMsg = name + ": " + editor.toPlainText(); if(notifyMsg.length() > 30) MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg.left(30) + QString("...")); else MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg); } // also update peer list. time_t now = time(NULL); QList<QTreeWidgetItem*> qlFoundParticipants=ui.participantsList->findItems(QString::fromStdString(gxs_id.toStdString()),Qt::MatchExactly,COLUMN_ID); if (qlFoundParticipants.count()!=0) qlFoundParticipants.at(0)->setText(COLUMN_ACTIVITY,QString::number(now)); if (now > lastUpdateListTime) { lastUpdateListTime = now; updateParticipantsList(); } }
VersionPage::VersionPage(QWidget *parent) : QWizardPage(parent) { setTitle(tr("Version")); QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); QGridLayout *grid = new QGridLayout; layout->addLayout(grid); QString release = MATDBRELEASESTR; release += " ("; release += QString::number(MATDBRELEASE); release += ")"; grid->addWidget(new QLabel(tr("MatDB Version")), 1, 0); grid->addWidget(new QLabel(release), 1, 1); grid->addItem(new QSpacerItem(10, 10, QSizePolicy::Maximum), 1, 2); grid->addWidget(new QLabel(tr("tag")), 2, 0); grid->addWidget(new QLabel(MATDBTAGSTR), 2, 1); grid->addItem(new QSpacerItem(10, 10, QSizePolicy::Maximum), 2, 2); grid->addWidget(new QLabel(tr("git version")), 3, 0); grid->addWidget(new QLabel(MATDBGITTAGSTR), 3, 1); grid->addItem(new QSpacerItem(10, 10, QSizePolicy::Maximum), 3, 2); grid->addWidget(new QLabel(tr("Qt Version")), 4, 0); grid->addWidget(new QLabel(qVersion()), 4, 1); grid->addItem(new QSpacerItem(10, 10, QSizePolicy::Maximum), 4, 2); QTextEdit *copyright = new QTextEdit(this); layout->addWidget(copyright); copyright->setReadOnly(true); QFile file(":/html/COPYRIGHT.html"); file.open(QFile::ReadOnly); copyright->setHtml(file.readAll()); file.close(); }
void wid_stranke::on_btn_kopiraj_clicked() { QClipboard *odlozisce = QApplication::clipboard(); QModelIndexList selectedList = ui->tbl_stranke->selectionModel()->selectedRows(); QString html_besedilo = "<table>"; html_besedilo += "<tr>"; html_besedilo += "<th>ID</th>"; html_besedilo += "<th>Ime/Naziv</th>"; html_besedilo += "<th>Priimek/Polni naziv</th>"; html_besedilo += "<th>Telefon</th>"; html_besedilo += "<th>GSM</th>"; html_besedilo += "<th>Elektronski naslov</th>"; html_besedilo += "<th>Izobrazevalna ustanova</th>"; html_besedilo += "<th>Tip stranke</th>"; html_besedilo += "</tr>"; for( int i = 0; i < selectedList.count(); i++) { html_besedilo += "<tr>"; for ( int a = 0; a < 8; a++ ) { html_besedilo += "<td>"; html_besedilo += ui->tbl_stranke->item(selectedList.at(i).row(), a)->text(); html_besedilo += "</td>"; } html_besedilo += "</tr>"; } html_besedilo += "</table>"; QTextEdit *textedit = new QTextEdit; textedit->setHtml(html_besedilo); html_besedilo = textedit->toHtml(); odlozisce->clear(); QMimeData *mimeData = new QMimeData(); mimeData->setData("text/html", html_besedilo.toUtf8()); odlozisce->setMimeData(mimeData, QClipboard::Clipboard); }
AboutWindow::AboutWindow() { QVBoxLayout *layout = new QVBoxLayout(this); layout->setAlignment(Qt::AlignHCenter); setWindowTitle(tr("About 3DMEditor")); QTextEdit *info = new QTextEdit; info->setHtml(tr("ABOUT_TEXT", "text of about window")); info->setReadOnly(true); layout->addWidget(info); QPushButton *ok = new QPushButton(tr("ok")); connect(ok, SIGNAL(clicked()), this, SLOT(close())); ok->setMaximumWidth(80); QHBoxLayout *hlayout = new QHBoxLayout; layout->addLayout(hlayout); hlayout->addWidget(ok); hlayout->setAlignment(Qt::AlignHCenter); }
My_About::My_About(QWidget *parent) : QDialog(parent) { QPushButton *okButton = new QPushButton(tr("OK")); connect(okButton, SIGNAL(clicked()),this, SLOT(close())); QTextEdit *bigEditor = new QTextEdit; //QTextBrowser *bigEditor = new QTextBrowser; bigEditor->setHtml(about2); //bigEditor->setOpenExternalLink(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setSizeConstraint(QLayout::SetNoConstraint); mainLayout->addWidget(bigEditor); mainLayout->addWidget(okButton); setLayout(mainLayout); setWindowTitle(tr("About Qt GUI")); //setWindowIcon(QIcon(":/icon/tidyicon")); }
void ClipboardDialog::on_listWidgetFormats_currentItemChanged( QListWidgetItem *current, QListWidgetItem *) { ui->actionRemove_Format->setEnabled(current != NULL); QTextEdit *edit = ui->textEditContent; QString mime = current ? current->text() : QString(); edit->clear(); const QByteArray bytes = m_data.value(mime).toByteArray(); if ( mime.startsWith(QString("image")) ) { edit->document()->addResource( QTextDocument::ImageResource, QUrl("data://1"), bytes ); edit->setHtml( QString("<img src=\"data://1\" />") ); } else { edit->setPlainText( dataToText(bytes, mime) ); } ui->labelProperties->setText( tr("<strong>Size:</strong> %1 bytes", "Size of data in bytes").arg(bytes.size()) ); }
void EditStyle::editTextClicked(int id) { QTextEdit* e = 0; switch (id) { case 0: e = evenHeaderL; break; case 1: e = evenHeaderC; break; case 2: e = evenHeaderR; break; case 3: e = oddHeaderL; break; case 4: e = oddHeaderC; break; case 5: e = oddHeaderR; break; case 6: e = evenFooterL; break; case 7: e = evenFooterC; break; case 8: e = evenFooterR; break; case 9: e = oddFooterL; break; case 10: e = oddFooterC; break; case 11: e = oddFooterR; break; } if (e == 0) return; e->setHtml(editHtml(e->toHtml(), tr("Edit HTML Text"))); }
InstallWizardLicensePage::InstallWizardLicensePage(const Aeb* pPackageDescriptor, unsigned int licenseNum, const QString& license, bool isHtml, QWidget* pParent) : QWizardPage(pParent) { setTitle("License Agreement"); setSubTitle("Please read the License Agreement below."); QLabel* pName = new QLabel(QString::fromStdString(pPackageDescriptor->getName()), this); QTextEdit* pLicense = new QTextEdit(this); pLicense->setReadOnly(true); if (isHtml) { pLicense->setHtml(license); } else { pLicense->setPlainText(license); } QRadioButton* pAccept = new QRadioButton("I Accept this License Agreement", this); QRadioButton* pReject = new QRadioButton("I Reject this License Agreement", this); pReject->setChecked(true); QVBoxLayout* pLayout = new QVBoxLayout(this); pLayout->setSpacing(5); pLayout->setMargin(10); pLayout->addWidget(pName); pLayout->addWidget(pLicense); pLayout->addWidget(pAccept); pLayout->addWidget(pReject); // Require pAccept to be checked before enabling the Next button registerField(QString("license %1*").arg(licenseNum), pAccept); }
bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value ) { if ( !editor ) return false; QgsVectorLayer::EditType editType = vl->editType( idx ); const QgsField &field = vl->pendingFields()[idx]; QVariant::Type myFieldType = field.type(); QSettings settings; QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString(); switch ( editType ) { case QgsVectorLayer::Classification: case QgsVectorLayer::UniqueValues: case QgsVectorLayer::Enumeration: case QgsVectorLayer::ValueMap: case QgsVectorLayer::ValueRelation: { QVariant v = value; QComboBox *cb = qobject_cast<QComboBox *>( editor ); if ( !cb ) return false; if ( v.isNull() ) { v = nullValue; } int idx = cb->findData( v ); if ( idx < 0 ) return false; cb->setCurrentIndex( idx ); } break; case QgsVectorLayer::DialRange: case QgsVectorLayer::SliderRange: case QgsVectorLayer::EditRange: { if ( myFieldType == QVariant::Int ) { if ( editType == QgsVectorLayer::EditRange ) { QSpinBox *sb = qobject_cast<QSpinBox *>( editor ); if ( !sb ) return false; sb->setValue( value.toInt() ); } else { QAbstractSlider *sl = qobject_cast<QAbstractSlider *>( editor ); if ( !sl ) return false; sl->setValue( value.toInt() ); } break; } else if ( myFieldType == QVariant::Double ) { QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( editor ); if ( !dsb ) return false; dsb->setValue( value.toDouble() ); } } case QgsVectorLayer::CheckBox: { QCheckBox *cb = qobject_cast<QCheckBox *>( editor ); if ( cb ) { QPair<QString, QString> states = vl->checkedState( idx ); cb->setChecked( value == states.first ); break; } } // fall-through case QgsVectorLayer::LineEdit: case QgsVectorLayer::UniqueValuesEditable: case QgsVectorLayer::Immutable: case QgsVectorLayer::UuidGenerator: default: { QLineEdit *le = qobject_cast<QLineEdit *>( editor ); QTextEdit *te = qobject_cast<QTextEdit *>( editor ); QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( editor ); if ( !le && !te && !pte ) return false; QString text; if ( value.isNull() ) { if ( myFieldType == QVariant::Int || myFieldType == QVariant::Double || myFieldType == QVariant::LongLong ) text = ""; else if ( editType == QgsVectorLayer::UuidGenerator ) text = QUuid::createUuid().toString(); else text = nullValue; } else { text = value.toString(); } if ( le ) le->setText( text ); if ( te ) te->setHtml( text ); if ( pte ) pte->setPlainText( text ); } break; case QgsVectorLayer::FileName: case QgsVectorLayer::Calendar: { QLineEdit* le = qobject_cast<QLineEdit*>( editor ); if ( !le ) { le = editor->findChild<QLineEdit *>(); } if ( !le ) { return false; } le->setText( value.toString() ); } break; } return true; }
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); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); MyInfo = new info(this); // ------------------------- Всякая красота ---------------------------- QSettings settings ("Other/config.ini", QSettings::IniFormat); settings.beginGroup("Settings"); this->setWindowTitle("FormUdod - " + settings.value("windowtitle", "Запись в объединения").toString()); settings.endGroup(); this->setWindowIcon(QIcon(":/icons/Icons/udod")); help = new QDialog(this); help->setWindowTitle(tr("Помощь")); help->setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); QTextEdit* textEdit = new QTextEdit; textEdit->setReadOnly(true); textEdit->setHtml(tr("Данная программа представляет собой клиент для работы с базой данных. Перед началом работы убедитесь, что соединение с базой установлено — " "в нижней части окна программы должна появиться соответствующая надпись. <b>Если соединение отсутствует, обратитесь к системному администратору.</b><br /><br />" "Если соединение установлено, заполните анкету. <b>Обратите внимание, что поля, помеченные символом *, обязательны для заполнения!</b> " "Если одно или несколько обязательных полей не заполнено, то при попытке сохранения программа выдаст соответствующее сообщения, а данные сохранены не будут.<br /><br />" "Для сохранения введённых данных нажмите <img src=:/icons/Icons/save.png/ height=20> <b>Сохранить</b> на панели инструментов и подтвердите действие, нажав <b>Да</b> во всплывающем окне, " "либо нажмите <b>Нет</b> для его отмены.<br /><br />" "Для очистки всех полей нажмите <img src=:/icons/Icons/clear.png/ height=20> <b>Очистить форму</b>. Обратите внимание, что при этом все введённые данные будут потеряны!<br /><br />" "Для получения информации о программе и лицензии нажмите <img src=:/icons/Icons/info.png/ height=20> <b>О программе</b>.<br /><br />" "<b>Изменение настроек программы может осуществляться только системным администратором.</b>")); QVBoxLayout* layout = new QVBoxLayout; QDialogButtonBox* button = new QDialogButtonBox(QDialogButtonBox::Ok); connect(button, SIGNAL(accepted()), help, SLOT(close())); layout->addWidget(textEdit); layout->addWidget(button); help->setLayout(layout); // --------------------------- Main ToolBar ---------------------------- // Иконки: http://www.flaticon.com/packs/web-application-ui/4 ui->mainToolBar->addAction(QIcon(":/icons/Icons/save.png"), tr("Сохранить"), this, SLOT(saveInfo())); ui->mainToolBar->addAction(QIcon(":/icons/Icons/clear.png"), tr("Очистить форму"), this, SLOT(clearForm())); ui->mainToolBar->addSeparator(); ui->mainToolBar->addAction(QIcon(":/icons/Icons/help.png"), tr("Помощь"), help, SLOT(show())); ui->mainToolBar->addAction(QIcon(":/icons/Icons/info.png"), tr("О программе"), MyInfo, SLOT(show())); names = new QRegularExpression("^[А-ЯЁ]{1}[а-яё]*(-[А-ЯЁ]{1}[а-яё]*)?$"); words = new QRegularExpression(); // Получение инфы обобъединениях QFile file ("Other/association.txt"); // Указываем название файла if(file.open(QIODevice::ReadOnly)) // Открываем файл для чтения { // Если файл успешно открыт QTextStream stream(&file); // Создаём поток текстового ввода/вывода if(stream.status() == QTextStream::Ok) { // Если поток создан успешно QStringList qsl; // Создаём список строк while (!stream.atEnd()) { // Считываем поочерёдно все строки, форматируя их QString str = stream.readLine().simplified().replace(QRegularExpression("-{2,}"), "-"); // Если строка не пустая и не комментарий if (!str.isEmpty() && str.at(0) != '#') qsl.append(str); // Заносим её в список } qsl.sort(); // Сортируем список qsl.prepend("- Не выбрано -"); // Добавляем 0й элемент ui->ass1->addItems(qsl); // Устанавливаем текст для ComboBox ui->ass2->addItems(qsl); ui->ass3->addItems(qsl); } file.close(); // Закрываем файл } // ----------------------------- DataBase ------------------------------ myDB = QSqlDatabase::addDatabase("QMYSQL"); // Указываем СУБД settings.beginGroup("Database"); myDB.setHostName(settings.value("hostname", "localhost").toString()); myDB.setDatabaseName(settings.value("dbname", "kcttTempDB").toString()); myDB.setPort(settings.value("port").toInt()); myDB.setUserName(settings.value("username").toString()); myDB.setPassword(settings.value("password").toString()); settings.endGroup(); QString status; if (myDB.open() && !myDB.isOpenError() && myDB.isValid()) // Открываем соединение status = tr("Соединение с базой установлено."); else status = tr("Ошибка соединения с основной базой: ") + myDB.lastError().text(); ui->lblStatus->setText(status); }
void PeersDialog::insertChat() { if (!rsMsgs->chatAvailable()) { // std::cerr << "no chat available." << std::endl ; return; } std::list<ChatInfo> newchat; if (!rsMsgs->getNewChat(newchat)) { std::cerr << "could not get new chat." << std::endl ; return; } std::cerr << "got new chat." << std::endl ; QTextEdit *msgWidget = ui.msgText; std::list<ChatInfo>::iterator it; /** A RshareSettings object used for saving/loading settings */ RshareSettings settings; uint chatflags = settings.getChatFlags(); /* add in lines at the bottom */ for(it = newchat.begin(); it != newchat.end(); it++) { std::string msg(it->msg.begin(), it->msg.end()); #ifdef PEERS_DEBUG std::cerr << "PeersDialog::insertChat(): " << msg << std::endl; #endif /* are they private? */ if (it->chatflags & RS_CHAT_PRIVATE) { PopupChatDialog *pcd = getPrivateChat(it->rsid, it->name, chatflags); pcd->addChatMsg(&(*it)); continue; } std::ostringstream out; QString currenttxt = msgWidget->toHtml(); QString extraTxt; QString timestamp = QDateTime::currentDateTime().toString("hh:mm:ss"); QString name = QString::fromStdString(it->name); QString line = "<span style=\"color:#C00000\">" + timestamp + "</span>" + "<span style=\"color:#2D84C9\"><strong>" + " " + name + "</strong></span>"; //std::cerr << "PeersDialog::insertChat(): 1.11\n"; historyKeeper.addMessage(name, "THIS", QString::fromStdWString(it->msg)); //std::cerr << "PeersDialog::insertChat(): 1.12\n"; extraTxt += line; extraTxt += QString::fromStdWString(it->msg); /* add it everytime */ currenttxt += extraTxt; QHashIterator<QString, QString> i(smileys); while(i.hasNext()) { i.next(); foreach(QString code, i.key().split("|")) currenttxt.replace(code, "<img src=\"" + i.value() + "\" />"); } msgWidget->setHtml(currenttxt); QScrollBar *qsb = msgWidget->verticalScrollBar(); qsb -> setValue(qsb->maximum()); } }
// Slot. void MainWindow::about() { QDialog aboutDialog(this); QVBoxLayout* layout = new QVBoxLayout(&aboutDialog); QTextEdit* textEdit = new QTextEdit(&aboutDialog); textEdit->setReadOnly(true); textEdit->setHtml( "<pre>" PROGRAM_NAME " " PROGRAM_VERSION "\n\n" "This program is free software: you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" "the Free Software Foundation, either version 3 of the License, or\n" "(at your option) any later version.\n\n" "This program is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License for more details.\n\n" "You should have received a copy of the GNU General Public License\n" "along with this program. If not, see http://www.gnu.org/licenses/.\n" "</pre>" "<hr/>" "<pre>" "This program uses code from:\n\n" "- The Gnuspeech project (http://www.gnu.org/software/gnuspeech/).\n\n" " Provided by David R. Hill, Leonard Manzara and Craig Schock.\n\n" " Gnuspeech is distributed under the terms of the GNU General Public License\n" " as published by the Free Software Foundation, either version 3 of the\n" " License, or (at your option) any later version.\n\n" "- Qt (http://www.qt.io/).\n\n" " Provided by Digia Plc.\n\n" " Qt Free Edition is distributed under the terms of the GNU LGPLv2.1 or LGPLv3,\n" " depending on the library (see http://www.qt.io/faq/).\n\n" "- PortAudio Portable Real-Time Audio Library (http://www.portaudio.com/).\n\n" " Provided by Ross Bencina and Phil Burk.\n\n" " PortAudio is distributed under these terms:\n" " \"Permission is hereby granted, free of charge, to any person obtaining a copy\n" " of this software and associated documentation files (the \"Software\"), to\n" " deal in the Software without restriction, including without limitation the\n" " rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n" " sell copies of the Software, and to permit persons to whom the Software is\n" " furnished to do so, subject to the following conditions:\n\n" " The above copyright notice and this permission notice shall be included in\n" " all copies or substantial portions of the Software.\n\n" " THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n" " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n" " DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n" " OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n" " USE OR OTHER DEALINGS IN THE SOFTWARE.\"\n\n" "</pre>" ); layout->addWidget(textEdit); QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &aboutDialog); layout->addWidget(buttonBox); connect(buttonBox, SIGNAL(accepted()), &aboutDialog, SLOT(accept())); aboutDialog.setWindowTitle(tr("About ") + PROGRAM_NAME); aboutDialog.resize(600, 550); aboutDialog.exec(); }
/* Layout Language \return Layout pointer or zero if error generated. */ QLayout* ur_qtLayout( UThread* ut, LayoutInfo& parent, const UCell* blkC ) { CBParser cbp; UBlockIter bi; LayoutInfo lo; const UCell* val; const UCell* setWord = 0; QWidget* wid = 0; int match; ur_blkSlice( ut, &bi, blkC ); cbp_beginParse( ut, &cbp, bi.it, bi.end, qEnv.layoutRules ); while( (match = cbp_matchRule( &cbp )) > -1 ) { switch( match ) { case LD_HBOX: case LD_VBOX: { wid = 0; lo.grid = 0; lo.box = new QBoxLayout( (match == LD_HBOX) ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom ); if( parent.layout() ) parent.addLayout( lo.box ); val = cbp.values + 1; //TODO: Handle error. ur_qtLayout( ut, lo, val ); } break; case LD_LABEL: { QString txt; if( ! getString( ut, cbp.values + 1, txt ) ) return 0; MAKE_WIDGET( SLabel ) pw->setText( txt ); } break; case LD_BUTTON: { MAKE_WIDGET( SButton ) pw->setText( qstring( cbp.values + 1 ) ); pw->setBlock( cbp.values + 2 ); } break; case LD_CHECKBOX: { MAKE_WIDGET( SCheck ) pw->setText( qstring( cbp.values + 1 ) ); } break; case LD_SPIN_BOX: { MAKE_WIDGET( SSpinBox ) pw->setRange( ur_int( cbp.values + 1 ), ur_int( cbp.values + 2 ) ); } break; case LD_COMBO: { MAKE_WIDGET( SCombo ) val = cbp.values + 1; if( ur_is(val, UT_GETWORD) ) { if( ! (val = ur_wordCell( ut, val )) ) return 0; } if( ur_is(val, UT_BLOCK) ) { UBlockIter bi2; ur_blkSlice( ut, &bi2, val ); ur_foreach( bi2 ) { if( ur_is(bi2.it, UT_STRING) ) pw->addItem( qstring( bi2.it ) ); } } else { pw->addItem( qstring( val ) ); } } break; case LD_SPACER: if( ! parent.box ) goto no_layout; parent.box->addStretch( 1 ); break; case LD_SPACE: if( ! parent.box ) goto no_layout; val = cbp.values + 1; parent.box->addSpacing( ur_int(val) ); break; case LD_TAB: { MAKE_WIDGET( STabWidget ) if( ! tabWidgetBlock( ut, pw, cbp.values + 1 ) ) return 0; } break; case LD_TIP: if( wid ) wid->setToolTip( qstring(cbp.values + 1) ); break; case LD_TITLE: if( qEnv.curWidget ) { QString str; if( ! getString( ut, cbp.values + 1, str ) ) return 0; qEnv.curWidget->setWindowTitle( str ); } break; case LD_RESIZE: if( qEnv.curWidget ) { val = cbp.values + 1; qEnv.curWidget->resize( val->coord.n[0], val->coord.n[1] ); } break; case LD_LINE_EDIT_STR: case LD_LINE_EDIT: { MAKE_WIDGET( SLineEdit ) if( match == LD_LINE_EDIT_STR ) pw->setText( qstring( cbp.values + 1 ) ); } break; case LD_LIST: { const UCell* hdr = cbp.values + 1; if( ur_is(hdr, UT_GETWORD) ) { if( ! (hdr = ur_wordCell( ut, hdr )) ) return 0; } val = cbp.values + 2; if( ur_is(val, UT_GETWORD) ) { if( ! (val = ur_wordCell( ut, val )) ) return 0; } MAKE_WIDGET( STreeView ) pw->setRootIsDecorated( false ); pw->setModel( new UTreeModel( pw, hdr, val ) ); } break; case LD_TEXT_EDIT_STR: case LD_TEXT_EDIT: { MAKE_WIDGET( STextEdit ) if( match == LD_TEXT_EDIT_STR ) { QString str; if( ! getString( ut, cbp.values + 1, str ) ) return 0; if( str[0] == '<' ) pw->setHtml( str ); else pw->setPlainText( str ); } } break; case LD_GROUP: case LD_GROUP_CHECKABLE: { MAKE_WIDGET( SGroup ) val = cbp.values + 1; if( match == LD_GROUP_CHECKABLE ) { const UCell* enabled; if( ! (enabled = ur_wordCell( ut, val )) ) return 0; pw->setCheckable( true ); pw->setChecked( ur_isTrue( enabled ) ); ++val; } pw->setTitle( qstring( val ) ); ++val; LayoutInfo lo2; QLayout* lr2 = ur_qtLayout(ut, lo2, val); if( ! lr2 ) return 0; pw->setLayout( lr2 ); } break; case LD_READ_ONLY: if( wid ) { QTextEdit* tedit = qobject_cast<QTextEdit*>( wid ); if( tedit ) tedit->setReadOnly( true ); } break; case LD_ON_EVENT: if( qEnv.curWidget ) { SWidget* sw = qobject_cast<SWidget*>( qEnv.curWidget ); if( sw ) sw->setEventBlock( cbp.values + 1 ); } break; case LD_STRING: if( wid ) { SCombo* combo = qobject_cast<SCombo*>( wid ); if( combo ) { combo->addItem( qstring( cbp.values ) ); break; } QTextEdit* texted = qobject_cast<QTextEdit*>( wid ); if( texted ) { QString str; cellToQString( cbp.values, str ); if( str[0] == '<' ) texted->setHtml( str ); else texted->setPlainText( str ); } } break; case LD_BLOCK: if( wid ) { SCombo* combo = qobject_cast<SCombo*>( wid ); if( combo ) { combo->setBlock( cbp.values ); break; } STreeView* tree = qobject_cast<STreeView*>( wid ); if( tree ) { tree->setBlock( cbp.values ); break; } } break; case LD_SET_WORD: setWord = cbp.values; break; case LD_GRID: val = cbp.values + 1; wid = 0; lo.box = 0; lo.grid = new QGridLayout; lo.columns = ur_int(val); lo.colN = 0; lo.rowN = 0; if( parent.layout() ) parent.addLayout( lo.grid ); ++val; //TODO: Handle error. ur_qtLayout( ut, lo, val ); break; case LD_PROGRESS: { MAKE_WIDGET( SProgress ) pw->setRange( 0, ur_int(cbp.values+1) ); } break; case LD_WEIGHT: if( parent.box && wid ) { parent.box->setStretchFactor(wid, ur_int(cbp.values+1)); } break; } }
BTAboutModuleDialog::BTAboutModuleDialog(QWidget* parent, CSwordModuleInfo* info) : QDialog(parent) { //Set the flag to destroy when closed - otherwise eats memory setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("Information About") + QString(" ") + info->name()); resize(650, 400); QVBoxLayout* vboxLayout = new QVBoxLayout(this); QTextEdit* textEdit = new QTextEdit(this); textEdit->setReadOnly(true); textEdit->setTextInteractionFlags(Qt::TextSelectableByMouse); vboxLayout->addWidget(textEdit); textEdit->setHtml(info->aboutText()); QDialogButtonBox* buttonBox = new QDialogButtonBox(this); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Close); vboxLayout->addWidget(buttonBox); QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); }