Example #1
0
        void catchException(const std::exception& ex) {
            QString error = QString::fromUtf8(ex.what());
            QString message = "<qt><b>qtfuzzylite</b> has experienced an internal error and will exit.<br><br>"
                    "Please report this error to &nbsp; <a href='mailto:[email protected]'>"
                    "[email protected]</a><br><br>"
                    "Your report will help to make <b>fuzzylite</b> and <b>qtfuzzylite</b> a better "
                    "free open source fuzzy logic library!<br><br>"
                    "Many thanks in advance for your help!"
                    "</qt>";
            QMessageBox x(NULL);
            x.setText(message);
            x.setWindowTitle("Internal Error");
            x.setIcon(QMessageBox::Critical);
            QLabel dummy;
            x.layout()->addWidget(&dummy);

            QLabel viewLabel("Error message:");
            QPlainTextEdit viewError;
            viewError.setReadOnly(true);
            viewError.setPlainText(error);
            viewError.setLineWrapMode(QPlainTextEdit::NoWrap);
            QFont tt("?");
            tt.setStyleHint(QFont::TypeWriter);
            tt.setPointSize(tt.pointSize() - 2);
            viewError.setFont(tt);

            QWidget* view = new QWidget;
            view->setLayout(new QVBoxLayout);
            view->layout()->addWidget(&viewLabel);
            view->layout()->addWidget(&viewError);
            x.layout()->addWidget(view);
            x.exec();
        }
Example #2
0
void GroupchatTopicDlg::addLanguage(const LanguageManager::LangId &id, const QString &text)
{
    QFont f;
    f.fromString(PsiOptions::instance()->getOption("options.ui.look.font.chat").toString());

    QPlainTextEdit *edit = new QPlainTextEdit(text);
    edit->setFont(f);
    edit->setProperty("langId", QVariant::fromValue<LanguageManager::LangId>(id));
    m_ui->twLang->addTab(edit, LanguageManager::languageName(id));
}
Example #3
0
DebugWidget::DebugWidget()
{
    this->setWindowTitle("Debug Log");
    this->setAttribute( Qt::WA_QuitOnClose, false ); //quit only when main window is closed
    QBoxLayout* layout = new QVBoxLayout();
    this->setLayout(layout);
    QPlainTextEdit *textEdit = new QPlainTextEdit(this);
    QFont font = QFont("Monospace");
    font.setStyleHint(QFont::TypeWriter);
    textEdit->setFont(font);
    textEdit->setReadOnly(true);
    layout->addWidget(textEdit);
    this->show();
    DEBUG_DISPLAY = textEdit;
}
Example #4
0
HexDumpWindow::HexDumpWindow(QString romFilePath, QWidget * parent) : QWidget(parent, Qt::Window)
{
	this->setWindowTitle(tr("Hex Dump"));

	QString dump = QString::fromStdString(disassembler::RomParser::hexDump(romFilePath.toStdString()));
	QPlainTextEdit* editor = new QPlainTextEdit(dump);
	editor->setFont(QFont ("Courier", 11));
	editor->setReadOnly(true);

	QHBoxLayout* layout = new QHBoxLayout;
	layout->addWidget(editor);

	this->setLayout(layout);
	this->setFixedSize(600, 600);
}
Example #5
0
ScriptLogWindow::ScriptLogWindow() : QWidget(nullptr)
{
	const QFont fixedFont =
		QFontDatabase::systemFont(QFontDatabase::FixedFont);

	QPlainTextEdit *edit = new QPlainTextEdit();
	edit->setReadOnly(true);
	edit->setFont(fixedFont);
	edit->setWordWrapMode(QTextOption::NoWrap);

	QHBoxLayout *buttonLayout = new QHBoxLayout();
	QPushButton *clearButton = new QPushButton(tr("Clear"));
	connect(clearButton, &QPushButton::clicked,
			this, &ScriptLogWindow::ClearWindow);
	QPushButton *closeButton = new QPushButton(tr("Close"));
	connect(closeButton, &QPushButton::clicked,
			this, &QDialog::hide);

	buttonLayout->addStretch();
	buttonLayout->addWidget(clearButton);
	buttonLayout->addWidget(closeButton);

	QVBoxLayout *layout = new QVBoxLayout();
	layout->addWidget(edit);
	layout->addLayout(buttonLayout);

	setLayout(layout);
	scriptLogWidget = edit;

	resize(600, 400);

	config_t *global_config = obs_frontend_get_global_config();
	const char *geom = config_get_string(global_config,
			"ScriptLogWindow", "geometry");
	if (geom != nullptr) {
		QByteArray ba = QByteArray::fromBase64(QByteArray(geom));
		restoreGeometry(ba);
	}

	setWindowTitle(obs_module_text("ScriptLogWindow"));

	connect(edit->verticalScrollBar(), &QAbstractSlider::sliderMoved,
			this, &ScriptLogWindow::ScrollChanged);
}
Example #6
0
About::About(QWidget * parent, Qt::WindowFlags f)
   : QDialog(parent, f)
{
   // stuff
   setWindowTitle("About LibreLibreCell");

   QLabel *versionLabel = new QLabel(QString("Git revision: %1").arg(LIBRELIBRECELL_VERSION));
   QPlainTextEdit *aboutBox = new QPlainTextEdit;
   QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);

   QVBoxLayout *vLayout = new QVBoxLayout;
   vLayout->addWidget(versionLabel);
   vLayout->addWidget(aboutBox, 1);
   vLayout->addSpacing(10);
   vLayout->addWidget(buttonBox);

   setLayout(vLayout);


   aboutBox->setReadOnly(true);
   aboutBox->setTabChangesFocus(true);
   aboutBox->setWordWrapMode(QTextOption::NoWrap);
   aboutBox->setLineWrapMode(QPlainTextEdit::NoWrap);
   aboutBox->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
   aboutBox->setFont(QFont("Monospace", 10));

   QFile readme(":/README.txt");
   if (readme.open(QIODevice::ReadOnly))
   {
      QTextStream stream(&readme);
      aboutBox->setPlainText(stream.readAll());
      readme.close();
   }
   else
   {
      aboutBox->setPlainText("Could not open README.txt.");
   }
   QFontMetrics fm(aboutBox->font());
   aboutBox->setMinimumSize(fm.width(QLatin1Char('m')) * 76, 450);

   connect(buttonBox, SIGNAL(accepted()),
               this, SLOT(accept()));
}
Example #7
0
void DevConsole::logToConsole(const QString &logText, const QString &channel, bool raise)
{
    QString target_channel = channel;

    if(channel == "System") //Prevent creation another "system" tab if switched another UI language
        target_channel = ui->tabWidget->tabText(0);

    for(int i = 0; i < ui->tabWidget->count(); ++i)
    {
        if(ui->tabWidget->tabText(i) == target_channel)
        {
            QPlainTextEdit *tarEdit = getEditByIndex(i);
            if(!tarEdit)
                return;
            tarEdit->appendPlainText(logText);
            tarEdit->verticalScrollBar()->setValue(tarEdit->verticalScrollBar()->maximum());
            if(raise) ui->tabWidget->setCurrentIndex(i);
            return;
        }
    }
    //create new channel
    QWidget *w = new QWidget();
    QGridLayout *l = new QGridLayout(w);
    l->setContentsMargins(0, 0, 0, 0);
    l->setSpacing(0);
    QPlainTextEdit *e = new QPlainTextEdit(w);
    l->addWidget(e, 0, 0, 1, 1);
    QPushButton *p = new QPushButton(w);
    l->addWidget(p, 1, 0, 1, 1);
    p->setFlat(true);
    p->connect(p, SIGNAL(clicked()), this, SLOT(clearCurrentLog()));
    p->setText(tr("Clear %1 Log").arg(target_channel));
    e->setReadOnly(true);
    e->setStyleSheet(ui->plainTextEdit->styleSheet());
    e->setFont(ui->plainTextEdit->font());
    e->appendPlainText(logText);
    e->verticalScrollBar()->setValue(e->verticalScrollBar()->maximum());
    ui->tabWidget->addTab(w, target_channel);
}
Example #8
0
void QtHelpers::GenAdjustWidgetAppearanceToOS(QWidget *rootWidget)
{
    if (rootWidget == NULL)
            return;

        QObject *child = NULL;
        QObjectList Containers;
        QObject *container  = NULL;
        QStringList DoNotAffect;

        // Make an exception list (Objects not to be affected)
        DoNotAffect.append("aboutTitleLabel");     // about Dialog
        DoNotAffect.append("aboutVersionLabel");   // about Dialog
        DoNotAffect.append("aboutCopyrightLabel"); // about Dialog
        DoNotAffect.append("aboutUrlLabel");       // about Dialog
        DoNotAffect.append("aboutLicenseLabel");   // about Dialog

        // Set sizes according to OS:
    #ifdef __APPLE__
        int ButtonHeight = 35;
        int cmbxHeight = 30;
        QFont cntrlFont("Myriad Pro", 14);
        QFont txtFont("Myriad Pro", 14);
    #elif _WIN32 // Win XP/7
        int ButtonHeight = 24;
        int cmbxHeight = 20;
        QFont cntrlFont("MS Shell Dlg 2", 8);
        QFont txtFont("MS Shell Dlg 2", 8);
    #else
        int ButtonHeight = 24;
        int cmbxHeight = 24;
        QFont cntrlFont("Ubuntu Condensed", 10);
        QFont txtFont("Ubuntu", 10);
    #endif

        // Append root to containers
        Containers.append(rootWidget);
        while (!Containers.isEmpty())
        {
            container = Containers.takeFirst();
            if (container != NULL)
            {
                for (int ChIdx=0; ChIdx < container->children().size(); ChIdx++)
                {
                    child = container->children()[ChIdx];
                    if (!child->isWidgetType() || DoNotAffect.contains(child->objectName()))
                        continue;
                    // Append containers to Stack for recursion
                    if (child->children().size() > 0)
                        Containers.append(child);
                    else
                    {
                        // Cast child object to button and label
                        // (if the object is not of the correct type, it will be NULL)
                        QPushButton *button = qobject_cast<QPushButton *>(child);
                        QLabel *label = qobject_cast<QLabel *>(child);
                        QComboBox *cmbx = qobject_cast<QComboBox *>(child);
                        QLineEdit *ln = qobject_cast<QLineEdit *>(child);
                        QTreeWidget *tree = qobject_cast<QTreeWidget *>(child);
                        QPlainTextEdit *plain = qobject_cast<QPlainTextEdit *>(child);
                        QCheckBox *check = qobject_cast<QCheckBox *>(child);
                        if (button != NULL)
                        {
                            button->setMinimumHeight(ButtonHeight); // Win
                            button->setMaximumHeight(ButtonHeight); // Win
                            button->setFont(cntrlFont);
                        }
                        else if (cmbx != NULL)
                        {
                            cmbx->setFont(cntrlFont);
                            cmbx->setMaximumHeight(cmbxHeight);
                        }
                        else if (label != NULL)
                            label->setFont(txtFont);
                        else if (ln != NULL)
                            ln->setFont(txtFont);
                        else if (tree != NULL)
                        {
                            tree->header()->setFont(txtFont);
                        }
                        else if (plain != NULL)
                            plain->setFont(txtFont);
                        else if (check != NULL)
                            check->setFont(txtFont);
                    }
                }
            }
        }
}
Example #9
0
dlgStdPad::dlgStdPad(_cfg_port *cfg_port, QWidget *parent = 0) : QDialog(parent) {
	QFont f9, f8;

	f9.setPointSize(9);
	f9.setWeight(QFont::Light);
	f8.setPointSize(8);
	f8.setWeight(QFont::Light);

	memset(&data, 0x00, sizeof(data));
	memcpy(&data.cfg, cfg_port, sizeof(_cfg_port));

	setupUi(this);

	setFont(parent->font());

	groupBox_controller->setTitle(tr("Controller %1 : Standard Pad").arg(cfg_port->id));
	tabWidget->setCurrentIndex(JOYSTICK);
	combo_id_init();

	for (int a = KEYBOARD; a <= JOYSTICK; a++) {
		QPlainTextEdit *txt;
		QPushButton *bt;

		txt = findChild<QPlainTextEdit *>("plainTextEdit_" + SPT(a) + "_info");

		if (txt->font().pointSize() > 9) {
			txt->setFont(f9);
		}

		bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Sequence");
		bt->setProperty("myType", QVariant(a));
		connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_in_sequence_clicked(bool)));

		bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Unset_all");
		bt->setProperty("myType", QVariant(a));
		connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_unset_all_clicked(bool)));

		bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Defaults");
		bt->setProperty("myType", QVariant(a));
		connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_defaults_clicked(bool)));

		for (int b = BUT_A; b < MAX_STD_PAD_BUTTONS; b++) {
			int vbutton = b + (a * MAX_STD_PAD_BUTTONS);
			QPushButton *unset;

			bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_" + SPB(b));
			unset = findChild<QPushButton *>("pushButton_" + SPT(a) + "_unset_" + SPB(b));

			if (bt->font().pointSize() > 9) {
				bt->setFont(f9);
			}
			if (unset->font().pointSize() > 8) {
				unset->setFont(f8);
			}

			if (a == KEYBOARD) {
				bt->setText(inpObject::kbd_keyval_to_name(data.cfg.port.input[a][b]));
			} else {
				bt->setText(uQString(jsv_to_name(data.cfg.port.input[a][b])));
			}

			bt->installEventFilter(this);
			bt->setProperty("myVbutton", QVariant(vbutton));
			unset->setProperty("myVbutton", QVariant(vbutton));

			connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_input_clicked(bool)));
			connect(unset, SIGNAL(clicked(bool)), this, SLOT(s_unset_clicked(bool)));
		}
	}

	{
		comboBox_Controller_type->addItem(tr("Auto"));
		comboBox_Controller_type->addItem(tr("Original"));
		comboBox_Controller_type->addItem(tr("3rd-party"));
		comboBox_Controller_type->setCurrentIndex(data.cfg.port.type_pad);
		connect(comboBox_Controller_type, SIGNAL(activated(int)), this,
				SLOT(s_combobox_controller_type_activated(int)));
	}

	for (int i = TURBOA; i <= TURBOB; i++) {
		QSlider *tb = findChild<QSlider *>("horizontalSlider_" + SPB(i + TRB_A));
		QLabel *label = findChild<QLabel *>("label_value_slider_" + SPB(i + TRB_A));

		tb->setRange(1, TURBO_BUTTON_DELAY_MAX);
		tb->setProperty("myTurbo", QVariant(i));
		tb->setValue(data.cfg.port.turbo[i].frequency);
		connect(tb, SIGNAL(valueChanged(int)), this, SLOT(s_slider_td_value_changed(int)));

		label->setFixedWidth(label->sizeHint().width());
		td_update_label(i, data.cfg.port.turbo[i].frequency);
	}

	pushButton_Apply->setProperty("myPointer", QVariant::fromValue(((void *)cfg_port)));
	connect(pushButton_Apply, SIGNAL(clicked(bool)), this, SLOT(s_apply_clicked(bool)));
	connect(pushButton_Discard, SIGNAL(clicked(bool)), this, SLOT(s_discard_clicked(bool)));

	setAttribute(Qt::WA_DeleteOnClose);
	setFixedSize(width(), height());

	setFocusPolicy(Qt::StrongFocus);
	groupBox_controller->setFocus(Qt::ActiveWindowFocusReason);

	data.joy.timer = new QTimer(this);
	connect(data.joy.timer, SIGNAL(timeout()), this, SLOT(s_pad_joy_read_timer()));

	data.seq.timer = new QTimer(this);
	connect(data.seq.timer, SIGNAL(timeout()), this, SLOT(s_pad_in_sequence_timer()));

	installEventFilter(this);
}