int Dialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: setInteger(); break; case 1: setDouble(); break; case 2: setItem(); break; case 3: setText(); break; case 4: setColor(); break; case 5: setFont(); break; case 6: setExistingDirectory(); break; case 7: setOpenFileName(); break; case 8: setOpenFileNames(); break; case 9: setSaveFileName(); break; case 10: criticalMessage(); break; case 11: informationMessage(); break; case 12: questionMessage(); break; case 13: warningMessage(); break; case 14: errorMessage(); break; default: ; } _id -= 15; } return _id; }
Dialogs::Dialogs(QWidget *parent) : QWidget(parent), ui(new Ui::Dialogs) { ui->setupUi(this); setWindowTitle(tr("Standard Dialogs")); ui->native_checkBox->setChecked(true); // signals connect(ui->integer_pushButton, SIGNAL(clicked()), this, SLOT(setInteger())); connect(ui->double_pushButton, SIGNAL(clicked()), this, SLOT(setDouble())); connect(ui->getItem_pushButton, SIGNAL(clicked()), this, SLOT(setItem())); connect(ui->getText_pushButton, SIGNAL(clicked()), this, SLOT(setText())); connect(ui->dir_pushButton, SIGNAL(clicked()), this, SLOT(setExistingDirectory())); connect(ui->openFile_pushButton, SIGNAL(clicked()), this, SLOT(setOpenFileName())); connect(ui->openFiles_pushButton, SIGNAL(clicked()), this, SLOT(setOpenFileNames())); connect(ui->critical_pushButton, SIGNAL(clicked()), this, SLOT(criticalMessage())); connect(ui->info_pushButton, SIGNAL(clicked()), this, SLOT(informationMessage())); connect(ui->quest_pushButton, SIGNAL(clicked()), this, SLOT(questionMessage())); connect(ui->warn_pushButton, SIGNAL(clicked()), this, SLOT(warningMessage())); connect(ui->error_pushButton, SIGNAL(clicked()), this, SLOT(errorMessage())); }
static void configApplyError( const QString &msg ) { criticalMessage( MainWindow::tr( "iTALC Management Console" ), msg ); }
/*! * \brief Obtain a backtrace and print it to stdout. * * If GDB can be used to get a backtrace then we use it, otherwise and only * if TA3D_BUILTIN_BACKTRACE_SUPPORT is defined, a backtrace is obtained * then writen into a log file. It will be displayed in stdout when gdb is missing. * After this call, the program will exit with a exit status code equals * to `-1`. * * \param signum Which signal was received */ void backtrace_handler (int signum) { // Some functions called at exit may crash, so we must disable signals in order // to prevent overwriting a useful log clear_signals(); // Get TA3D's PID pid_t mypid = getpid(); // Try to get a stack trace from GDB String::Vector threads; TA3D::System::run_command(String("gdb --pid=") << mypid << " -ex \"info threads\" --batch").split(threads, "\n"); if (!threads.empty()) { String cmd; cmd << "gdb --pid=" << mypid << " -ex \"info threads\""; for(size_t i = 0 ; i < threads.size() ; ++i) { String &line = threads[i]; if (line.startsWith('[') || line.startsWith("0x") || line.startsWith('#')) continue; if (line.startsWith('*')) { line[0] = ' '; line.trimLeft(' '); } const int id = line.to<int>(); if (id <= 0) continue; cmd << " -ex \"thread " << id << "\" -ex bt"; } cmd << " --batch"; const String trace = TA3D::System::run_command(cmd); if (!trace.empty()) { bug_reporter(trace); exit(-1); } } // If GDB is not available or returned an error we must find another way ... this is now platform dependent # ifdef TA3D_BUILTIN_BACKTRACE_SUPPORT // Retrieving a backtrace void *array[400]; int size = backtrace (array, 400); char** strings = backtrace_symbols(array, size); // Try to log it Yuni::Core::IO::File::Stream m_File(String(TA3D::Paths::Logs) << "backtrace.txt", Yuni::Core::IO::OpenMode::write); if(m_File.opened()) { m_File << "received signal " << strsignal( signum ) << "\n"; m_File << "Obtained " << size << " stack frames.\n"; for (int i = 0; i < size; ++i) m_File << strings[i] << "\n"; m_File.flush(); m_File.close(); printf("received signal %s\n", strsignal( signum )); printf ("Obtained %d stack frames.\n", static_cast<int>(size)); for (int i = 0; i < size; ++i) printf ("%s\n", strings[i]); String szErrReport; szErrReport << "An error has occured.\nDebugging information have been logged to:\n" << TA3D::Paths::Logs << "backtrace.txt\nPlease report to our forums (http://www.ta3d.org/)\nand keep this file, it'll help us debugging.\n"; criticalMessage(szErrReport); } else { // The file is not opened // The backtrace will be directly to stdout instead. printf("received signal %s\n", strsignal(signum)); printf("couldn't open file for writing!!\n"); printf ("Obtained %d stack frames.\n", static_cast<int>(size)); for (int i = 0; i < size; ++i) printf ("%s\n", strings[i]); } free(strings); # else // ifdef TA3D_BUILTIN_BACKTRACE_SUPPORT // The backtrace support is disabled: warns the user String szErrReport = "An error has occured.\nDebugging information could not be logged.\nPlease report to our forums (http://www.ta3d.org/) so we can fix it."; criticalMessage(szErrReport); # endif // ifdef TA3D_BUILTIN_BACKTRACE_SUPPORT exit(-1); }
Dialog::Dialog(QWidget *parent) : QWidget(parent) { QVBoxLayout *mainLayout = new QVBoxLayout(this); QToolBox *toolbox = new QToolBox; mainLayout->addWidget(toolbox); errorMessageDialog = new QErrorMessage(this); int frameStyle = QFrame::Sunken | QFrame::Panel; integerLabel = new QLabel; integerLabel->setFrameStyle(frameStyle); QPushButton *integerButton = new QPushButton(tr("QInputDialog::get&Int()")); doubleLabel = new QLabel; doubleLabel->setFrameStyle(frameStyle); QPushButton *doubleButton = new QPushButton(tr("QInputDialog::get&Double()")); itemLabel = new QLabel; itemLabel->setFrameStyle(frameStyle); QPushButton *itemButton = new QPushButton(tr("QInputDialog::getIte&m()")); textLabel = new QLabel; textLabel->setFrameStyle(frameStyle); QPushButton *textButton = new QPushButton(tr("QInputDialog::get&Text()")); multiLineTextLabel = new QLabel; multiLineTextLabel->setFrameStyle(frameStyle); QPushButton *multiLineTextButton = new QPushButton(tr("QInputDialog::get&MultiLineText()")); colorLabel = new QLabel; colorLabel->setFrameStyle(frameStyle); QPushButton *colorButton = new QPushButton(tr("QColorDialog::get&Color()")); fontLabel = new QLabel; fontLabel->setFrameStyle(frameStyle); QPushButton *fontButton = new QPushButton(tr("QFontDialog::get&Font()")); directoryLabel = new QLabel; directoryLabel->setFrameStyle(frameStyle); QPushButton *directoryButton = new QPushButton(tr("QFileDialog::getE&xistingDirectory()")); openFileNameLabel = new QLabel; openFileNameLabel->setFrameStyle(frameStyle); QPushButton *openFileNameButton = new QPushButton(tr("QFileDialog::get&OpenFileName()")); openFileNamesLabel = new QLabel; openFileNamesLabel->setFrameStyle(frameStyle); QPushButton *openFileNamesButton = new QPushButton(tr("QFileDialog::&getOpenFileNames()")); saveFileNameLabel = new QLabel; saveFileNameLabel->setFrameStyle(frameStyle); QPushButton *saveFileNameButton = new QPushButton(tr("QFileDialog::get&SaveFileName()")); criticalLabel = new QLabel; criticalLabel->setFrameStyle(frameStyle); QPushButton *criticalButton = new QPushButton(tr("QMessageBox::critica&l()")); informationLabel = new QLabel; informationLabel->setFrameStyle(frameStyle); QPushButton *informationButton = new QPushButton(tr("QMessageBox::i&nformation()")); questionLabel = new QLabel; questionLabel->setFrameStyle(frameStyle); QPushButton *questionButton = new QPushButton(tr("QMessageBox::&question()")); warningLabel = new QLabel; warningLabel->setFrameStyle(frameStyle); QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()")); errorLabel = new QLabel; errorLabel->setFrameStyle(frameStyle); QPushButton *errorButton = new QPushButton(tr("QErrorMessage::showM&essage()")); connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger())); connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble())); connect(itemButton, SIGNAL(clicked()), this, SLOT(setItem())); connect(textButton, SIGNAL(clicked()), this, SLOT(setText())); connect(multiLineTextButton, SIGNAL(clicked()), this, SLOT(setMultiLineText())); connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor())); connect(fontButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(directoryButton, SIGNAL(clicked()), this, SLOT(setExistingDirectory())); connect(openFileNameButton, SIGNAL(clicked()), this, SLOT(setOpenFileName())); connect(openFileNamesButton, SIGNAL(clicked()), this, SLOT(setOpenFileNames())); connect(saveFileNameButton, SIGNAL(clicked()), this, SLOT(setSaveFileName())); connect(criticalButton, SIGNAL(clicked()), this, SLOT(criticalMessage())); connect(informationButton, SIGNAL(clicked()), this, SLOT(informationMessage())); connect(questionButton, SIGNAL(clicked()), this, SLOT(questionMessage())); connect(warningButton, SIGNAL(clicked()), this, SLOT(warningMessage())); connect(errorButton, SIGNAL(clicked()), this, SLOT(errorMessage())); QWidget *page = new QWidget; QGridLayout *layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->setColumnMinimumWidth(1, 250); layout->addWidget(integerButton, 0, 0); layout->addWidget(integerLabel, 0, 1); layout->addWidget(doubleButton, 1, 0); layout->addWidget(doubleLabel, 1, 1); layout->addWidget(itemButton, 2, 0); layout->addWidget(itemLabel, 2, 1); layout->addWidget(textButton, 3, 0); layout->addWidget(textLabel, 3, 1); layout->addWidget(multiLineTextButton, 4, 0); layout->addWidget(multiLineTextLabel, 4, 1); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0); toolbox->addItem(page, tr("Input Dialogs")); const QString doNotUseNativeDialog = tr("Do not use native dialog"); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(colorButton, 0, 0); layout->addWidget(colorLabel, 0, 1); colorDialogOptionsWidget = new DialogOptionsWidget; colorDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QColorDialog::DontUseNativeDialog); colorDialogOptionsWidget->addCheckBox(tr("Show alpha channel") , QColorDialog::ShowAlphaChannel); colorDialogOptionsWidget->addCheckBox(tr("No buttons") , QColorDialog::NoButtons); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0); layout->addWidget(colorDialogOptionsWidget, 2, 0, 1 ,2); toolbox->addItem(page, tr("Color Dialog")); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(fontButton, 0, 0); layout->addWidget(fontLabel, 0, 1); fontDialogOptionsWidget = new DialogOptionsWidget; fontDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QFontDialog::DontUseNativeDialog); fontDialogOptionsWidget->addCheckBox(tr("No buttons") , QFontDialog::NoButtons); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0); layout->addWidget(fontDialogOptionsWidget, 2, 0, 1 ,2); toolbox->addItem(page, tr("Font Dialog")); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(directoryButton, 0, 0); layout->addWidget(directoryLabel, 0, 1); layout->addWidget(openFileNameButton, 1, 0); layout->addWidget(openFileNameLabel, 1, 1); layout->addWidget(openFileNamesButton, 2, 0); layout->addWidget(openFileNamesLabel, 2, 1); layout->addWidget(saveFileNameButton, 3, 0); layout->addWidget(saveFileNameLabel, 3, 1); fileDialogOptionsWidget = new DialogOptionsWidget; fileDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QFileDialog::DontUseNativeDialog); fileDialogOptionsWidget->addCheckBox(tr("Show directories only"), QFileDialog::ShowDirsOnly); fileDialogOptionsWidget->addCheckBox(tr("Do not resolve symlinks"), QFileDialog::DontResolveSymlinks); fileDialogOptionsWidget->addCheckBox(tr("Do not confirm overwrite"), QFileDialog::DontConfirmOverwrite); fileDialogOptionsWidget->addCheckBox(tr("Do not use sheet"), QFileDialog::DontUseSheet); fileDialogOptionsWidget->addCheckBox(tr("Readonly"), QFileDialog::ReadOnly); fileDialogOptionsWidget->addCheckBox(tr("Hide name filter details"), QFileDialog::HideNameFilterDetails); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 4, 0); layout->addWidget(fileDialogOptionsWidget, 5, 0, 1 ,2); toolbox->addItem(page, tr("File Dialogs")); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(criticalButton, 0, 0); layout->addWidget(criticalLabel, 0, 1); layout->addWidget(informationButton, 1, 0); layout->addWidget(informationLabel, 1, 1); layout->addWidget(questionButton, 2, 0); layout->addWidget(questionLabel, 2, 1); layout->addWidget(warningButton, 3, 0); layout->addWidget(warningLabel, 3, 1); layout->addWidget(errorButton, 4, 0); layout->addWidget(errorLabel, 4, 1); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0); toolbox->addItem(page, tr("Message Boxes")); setWindowTitle(tr("Standard Dialogs")); }
Dialog::Dialog(QWidget *parent) : QDialog(parent) { errorMessageDialog = new QErrorMessage(this); int frameStyle = QFrame::Sunken | QFrame::Panel; integerLabel = new QLabel; integerLabel->setFrameStyle(frameStyle); QPushButton *integerButton = new QPushButton(tr("QInputDialog::get&Integer()")); doubleLabel = new QLabel; doubleLabel->setFrameStyle(frameStyle); QPushButton *doubleButton = new QPushButton(tr("QInputDialog::get&Double()")); itemLabel = new QLabel; itemLabel->setFrameStyle(frameStyle); QPushButton *itemButton = new QPushButton(tr("QInputDialog::getIte&m()")); textLabel = new QLabel; textLabel->setFrameStyle(frameStyle); QPushButton *textButton = new QPushButton(tr("QInputDialog::get&Text()")); colorLabel= new QLabel; colorLabel->setFrameStyle(frameStyle); QPushButton *colorButton = new QPushButton(tr("QColorDialog::get&Color()")); fontLabel = new QLabel; fontLabel->setFrameStyle(frameStyle); QPushButton *fontButton = new QPushButton(tr("QFontDialog::get&Font()")); directoryLabel = new QLabel; directoryLabel->setFrameStyle(frameStyle); QPushButton *directoryButton = new QPushButton(tr("QFileDialog::getE&xistingDirectory()")); openFileNameLabel = new QLabel; openFileNameLabel->setFrameStyle(frameStyle); QPushButton *openFileNameButton = new QPushButton(tr("QFileDialog::get&OpenFileName()")); openFileNamesLabel = new QLabel; openFileNamesLabel->setFrameStyle(frameStyle); QPushButton *openFileNamesButton = new QPushButton(tr("QFileDialog::&getOpenFileNames()")); saveFileNameLabel = new QLabel; saveFileNameLabel->setFrameStyle(frameStyle); QPushButton *saveFileNameButton = new QPushButton(tr("QFileDialog::get&SaveFileName()")); criticalLabel = new QLabel; criticalLabel->setFrameStyle(frameStyle); QPushButton *criticalButton = new QPushButton(tr("QMessageBox::critica&l()")); informationLabel = new QLabel; informationLabel->setFrameStyle(frameStyle); QPushButton *informationButton = new QPushButton(tr("QMessageBox::i&nformation()")); questionLabel = new QLabel; questionLabel->setFrameStyle(frameStyle); QPushButton *questionButton = new QPushButton(tr("QMessageBox::&question()")); warningLabel = new QLabel; warningLabel->setFrameStyle(frameStyle); QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()")); errorLabel = new QLabel; errorLabel->setFrameStyle(frameStyle); QPushButton *errorButton = new QPushButton(tr("QMessageBox::&error()")); connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger())); connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble())); connect(itemButton, SIGNAL(clicked()), this, SLOT(setItem())); connect(textButton, SIGNAL(clicked()), this, SLOT(setText())); connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor())); connect(fontButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(directoryButton, SIGNAL(clicked()), this, SLOT(setExistingDirectory())); connect(openFileNameButton, SIGNAL(clicked()), this, SLOT(setOpenFileName())); connect(openFileNamesButton, SIGNAL(clicked()), this, SLOT(setOpenFileNames())); connect(saveFileNameButton, SIGNAL(clicked()), this, SLOT(setSaveFileName())); connect(criticalButton, SIGNAL(clicked()), this, SLOT(criticalMessage())); connect(informationButton, SIGNAL(clicked()), this, SLOT(informationMessage())); connect(questionButton, SIGNAL(clicked()), this, SLOT(questionMessage())); connect(warningButton, SIGNAL(clicked()), this, SLOT(warningMessage())); connect(errorButton, SIGNAL(clicked()), this, SLOT(errorMessage())); native = new QCheckBox(this); native->setText("Use native file dialog"); native->setChecked(true); #ifndef Q_WS_WIN #ifndef Q_OS_MAC native->hide(); #endif #endif QGridLayout *layout = new QGridLayout; layout->setColumnStretch(1, 1); layout->setColumnMinimumWidth(1, 250); layout->addWidget(integerButton, 0, 0); layout->addWidget(integerLabel, 0, 1); layout->addWidget(doubleButton, 1, 0); layout->addWidget(doubleLabel, 1, 1); layout->addWidget(itemButton, 2, 0); layout->addWidget(itemLabel, 2, 1); layout->addWidget(textButton, 3, 0); layout->addWidget(textLabel, 3, 1); layout->addWidget(colorButton, 4, 0); layout->addWidget(colorLabel, 4, 1); layout->addWidget(fontButton, 5, 0); layout->addWidget(fontLabel, 5, 1); layout->addWidget(directoryButton, 6, 0); layout->addWidget(directoryLabel, 6, 1); layout->addWidget(openFileNameButton, 7, 0); layout->addWidget(openFileNameLabel, 7, 1); layout->addWidget(openFileNamesButton, 8, 0); layout->addWidget(openFileNamesLabel, 8, 1); layout->addWidget(saveFileNameButton, 9, 0); layout->addWidget(saveFileNameLabel, 9, 1); layout->addWidget(criticalButton, 10, 0); layout->addWidget(criticalLabel, 10, 1); layout->addWidget(informationButton, 11, 0); layout->addWidget(informationLabel, 11, 1); layout->addWidget(questionButton, 12, 0); layout->addWidget(questionLabel, 12, 1); layout->addWidget(warningButton, 13, 0); layout->addWidget(warningLabel, 13, 1); layout->addWidget(errorButton, 14, 0); layout->addWidget(errorLabel, 14, 1); layout->addWidget(native, 15, 0); setLayout(layout); setWindowTitle("Standard Dialogs"); }