void ChatRoom::push_text(const char *from, const char *message, QString &msgid, bool me) { QTextBrowser *text = ui->textBrowser; QString author; QString msg; author.sprintf("%s", from); if(!msgid.isEmpty()){ author += "\tmsgid:" + msgid; } msg.sprintf("%s",message); text->append(author); text->append(msg); }
int main(int argc, char ** argv) { using Q = QObject; QApplication app{argc, argv}; QWidget ui; QVBoxLayout layout{&ui}; QTextBrowser log; QProgressBar bar; QPushButton scan{"Scan localhost"}; layout.addWidget(&log); layout.addWidget(&bar); layout.addWidget(&scan); bar.setRange(1, 65535); ui.show(); Scanner scanner; Q::connect(&scan, &QPushButton::clicked, &scanner, [&]{ scan.setEnabled(false); scanner.start(); }); Q::connect(&scanner, &Scanner::hasResult, &log, [&](int port, bool isOpen){ bar.setValue(port); if (!isOpen) return; auto color = isOpen ? QStringLiteral("green") : QStringLiteral("red"); auto state = isOpen ? QStringLiteral("open") : QStringLiteral("closed"); log.append(QStringLiteral("<font color=\"%1\">Port %2 is %3.</font><br/>"). arg(color).arg(port).arg(state)); }); Q::connect(&scanner, &Scanner::done, &scan, [&]{ bar.reset(); scan.setEnabled(true); }); return app.exec(); }
void MainWindow::dmesgTab() { QTextBrowser *browser = new QTextBrowser(this); int index = ui->tabWidget->addTab(browser, tr("dmesg log")); ui->tabWidget->setTabIcon(index, QIcon::fromTheme("text-x-script")); ui->tabWidget->setCurrentIndex(index); QByteArray data = pro.readAllStandardOutput(); browser->append(data); }
void Tray::on_ShowLog_triggered() { QMainWindow *mw = new QMainWindow(); mw->setAttribute(Qt::WA_DeleteOnClose); QTextBrowser *tb = new QTextBrowser(); mw->setCentralWidget(tb); mw->setWindowTitle(QString::fromLatin1("Murmur -- %1").arg(MUMBLE_RELEASE)); connect(le, SIGNAL(newLogEntry(const QString &)), tb, SLOT(append(const QString &))); foreach(const QString &m, qlLog) tb->append(m); mw->show(); }
int setCharProperty(GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal) { QTextBrowser *qw; QString text; qw=(QTextBrowser*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL); assert(qw); if (value) text=QT4_Gui::extractHtml(value); switch(prop) { case GWEN_DialogProperty_Value: qw->setText(""); qw->append(text); return 0; case GWEN_DialogProperty_AddValue: qw->append(text); return 0; case GWEN_DialogProperty_ClearValues: qw->setText(""); return 0; default: break; } DBG_WARN(GWEN_LOGDOMAIN, "Function is not appropriate for this type of widget (%s)", GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget))); return GWEN_ERROR_INVALID; };
void MainWindow::doc() { std::ifstream in; std::string s,line; in.open("doc/help",ios::in); while (getline(in,line)) { s += line + "\n"; } in.close(); QString qstr = QString::fromStdString(s); //img_label->setText(qstr); QTextBrowser *doc = new QTextBrowser(); doc->append(qstr); doc->show(); doc->setDocumentTitle(tr("Help")); }
//@Override /*public*/ void XmlFileLocationAction::actionPerformed(ActionEvent* ev) { /*final*/ QString user = FileUtil::getUserFilesPath(); /*final*/ QString roster = Roster::getDefault()->getRosterLocation(); /*final*/ QString profile = FileUtil::getProfilePath(); /*final*/ QString settings = FileUtil::getPreferencesPath(); /*final*/ QString scripts = FileUtil::getScriptsPath(); /*final*/ QString prog = System::getProperty("user.dir"); /*final*/ QString log = System::getProperty("jmri.log.path"); QString configName = System::getProperty("org.jmri.Apps.configFilename"); if (!( File(configName).isAbsolute())) { // must be relative, but we want it to // be relative to the preferences directory configName = profile + configName; } JFrame* frame = new JmriJFrame(); // to ensure fits frame->setTitle(tr("Locations")); QWidget* pane = new QWidget(); pane->setLayout(new QVBoxLayout); //(pane, BoxLayout.Y_AXIS)); QWidget* buttons = new QWidget(); buttons->setLayout(new FlowLayout()); pane->layout()->addWidget(buttons); QPushButton* b = new QPushButton("Open User Files Location"); buttons->layout()->addWidget(b); // b.addActionListener(new ActionListener() { // //@Override // /*public*/ void actionPerformed(ActionEvent event) { // try { // Desktop.getDesktop().open(new File(user)); // } catch (IOException e) { // XmlFileLocationAction.log.error("Error when opening user files location: " + e); // } catch (UnsupportedOperationException e) { // XmlFileLocationAction.log.error("Error when opening user files location: " + e); // } // } // }); connect(b, SIGNAL(clicked(bool)), this, SLOT(on_openUserFilesButton())); b = new QPushButton("Open Roster Location"); buttons->layout()->addWidget(b); // b.addActionListener(new ActionListener() { // @Override // /*public*/ void actionPerformed(ActionEvent event) { // try { // Desktop.getDesktop().open(new java.io.File(roster)); // } catch (java.io.IOException e) { // XmlFileLocationAction.log.error("Error when opening roster location: " + e); // } catch (UnsupportedOperationException e) { // XmlFileLocationAction.log.error("Error when opening roster location: " + e); // } // } // }); connect(b, SIGNAL(clicked(bool)), this, SLOT(on_openRosterButton())); b = new QPushButton("Open Profile Location"); buttons->layout()->addWidget(b); // b.addActionListener(new ActionListener() { // @Override // /*public*/ void actionPerformed(ActionEvent event) { // try { // Desktop.getDesktop().open(new java.io.File(profile)); // } catch (java.io.IOException e) { // XmlFileLocationAction.log.error("Error when opening profile location: " + e); // } catch (UnsupportedOperationException e) { // XmlFileLocationAction.log.error("Error when opening profile location: " + e); // } // } // }); connect(b, SIGNAL(clicked(bool)), this, SLOT(on_openProfileButton())); b = new QPushButton("Open Settings Location"); buttons->layout()->addWidget(b); // b.addActionListener(new ActionListener() { // @Override // /*public*/ void actionPerformed(ActionEvent event) { // try { // Desktop.getDesktop().open(new java.io.File(settings)); // } catch (java.io.IOException e) { // XmlFileLocationAction.log.error("Error when opening settings location: " + e); // } catch (UnsupportedOperationException e) { // XmlFileLocationAction.log.error("Error when opening settings location: " + e); // } // } // }); connect(b, SIGNAL(clicked(bool)), this, SLOT(on_openSettingsButton())); b = new QPushButton("Open Scripts Location"); buttons->layout()->addWidget(b); // b.addActionListener(new ActionListener() { // @Override // /*public*/ void actionPerformed(ActionEvent event) { // try { // Desktop.getDesktop().open(new java.io.File(scripts)); // } catch (java.io.IOException e) { // XmlFileLocationAction.log.error("Error when opening scripts location: " + e); // } catch (UnsupportedOperationException e) { // XmlFileLocationAction.log.error("Error when opening scripts location: " + e); // } // } // }); connect(b, SIGNAL(clicked(bool)), this, SLOT(on_openScriptsButton(ActionEvent*))); b = new QPushButton("Open Program Location"); buttons->layout()->addWidget(b); // b.addActionListener(new ActionListener() { // @Override // /*public*/ void actionPerformed(ActionEvent event) { // try { // Desktop.getDesktop().open(new java.io.File(prog)); // } catch (java.io.IOException e) { // XmlFileLocationAction.log.error("Error when opening program location: " + e); // } catch (UnsupportedOperationException e) { // XmlFileLocationAction.log.error("Error when opening program location: " + e); // } // } // }); connect(b, SIGNAL(clicked(bool)), this, SLOT(on_openProgramButton())); b = new QPushButton("Open Log Files Location"); buttons->layout()->addWidget(b); // b.addActionListener(new ActionListener() { // @Override // /*public*/ void actionPerformed(ActionEvent event) { // try { // Desktop.getDesktop().open(new java.io.File(log)); // } catch (java.io.IOException e) { // XmlFileLocationAction.log.error("Error when opening log files location: " + e); // } catch (UnsupportedOperationException e) { // XmlFileLocationAction.log.error("Error when opening log files location: " + e); // } // } // }); connect(b, SIGNAL(clicked(bool)), this, SLOT(on_openLogFilesButton())); //QScrollArea* scroll = new JScrollPane(pane); //frame.getContentPane().add(scroll); //QVBoxLayout* thisLayout = new QVBoxLayout(frame->getContentPane()); QTextBrowser* textPane = new QTextBrowser(); //textPane->setEditable(false); pane->layout()->addWidget(textPane); frame->getContentPane()->layout()->addWidget(pane); textPane->append("User Files Location: " + user + "\n"); textPane->append("Roster Location: " + roster + "\n"); textPane->append("Profile Location: " + profile + "\n"); textPane->append("Settings Location: " + settings + "\n"); textPane->append("Current Config file: " + configName + "\n"); textPane->append("Scripts Location: " + scripts + "\n"); textPane->append("Program Location: " + prog + "\n"); textPane->append("Log Files Location: " + log + "\n"); addLogFiles(textPane, log); frame->adjustSize(); frame->setVisible(true); }
void ConsoleOutput::print(QString msg, QString programTitle) { QTextBrowser* browser = tab(programTitle); browser->append(msg); }