本文整理汇总了C++中QMessageBox::button方法的典型用法代码示例。如果您正苦于以下问题:C++ QMessageBox::button方法的具体用法?C++ QMessageBox::button怎么用?C++ QMessageBox::button使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMessageBox
的用法示例。
在下文中一共展示了QMessageBox::button方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: choosePrintCharts
void LevelOneDec::choosePrintCharts()
{
QMessageBox *pmbx = new QMessageBox(QMessageBox::Information,
tr("Print"),
tr("What is the chart you want to print?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Close);
pmbx->button(QMessageBox::Yes)->setText(tr("Phase Coordinates"));
pmbx->button(QMessageBox::No)->setText(tr("Available Deviations"));
int n = pmbx->exec();
delete pmbx;
if (n == QMessageBox::Yes)
{
levelOneChart->printLevelOnePlot();
return;
}
else if (n == QMessageBox::No)
{
levelOneMuChart->printLevelOnePlot();
return;
}
else if (n == QMessageBox::Close)
{
return;
}
}
示例2: main
int main(int argc, char *argv[])
{
#if _DEBUG || (__GNUC__ && !NDEBUG)
#ifdef _WIN32
const char *logfilepath = "./resultsviewer.log";
#else
const char *logfilepath = "/var/log/resultsviewer.log";
#endif
openstudio::Logger::instance().standardOutLogger().setLogLevel(Debug);
openstudio::FileLogSink fileLog(openstudio::toPath(logfilepath));
fileLog.setLogLevel(Debug);
#else
openstudio::Logger::instance().standardOutLogger().setLogLevel(Warn);
#endif
bool cont = true;
while(cont) {
cont = false;
// Make the run path the default plugin search location
QCoreApplication::addLibraryPath(openstudio::toQString(openstudio::getApplicationRunDirectory()));
QApplication qApplication(argc,argv);
openstudio::Application::instance().setApplication(&qApplication);
try {
resultsviewer::MainWindow w;
w.show();
return qApplication.exec();
} catch (const std::exception &e) {
LOG_FREE(Fatal, "ResultsViewer", "An unhandled exception has occurred: " << e.what());
cont = true;
QMessageBox msgBox;
msgBox.setWindowTitle("Unhandled Exception");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("An unhandled exception has occurred.");
msgBox.setInformativeText(e.what());
msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
msgBox.button(QMessageBox::Retry)->setText("Relaunch");
if (msgBox.exec() == QMessageBox::Close) {
cont = false;
}
} catch (...) {
LOG_FREE(Fatal, "ResultsViewer", "An unknown exception has occurred.");
cont = true;
QMessageBox msgBox;
msgBox.setWindowTitle("Unknown Exception");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("An unknown exception has occurred.");
msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
msgBox.button(QMessageBox::Retry)->setText("Relaunch");
if (msgBox.exec() == QMessageBox::Close) {
cont = false;
}
}
}
}
示例3:
bool alele::AccountHolder::showAuthenticationPopup(string const& _title, string const& _text)
{
QMessageBox userInput;
userInput.setText(QString::fromStdString(_title));
userInput.setInformativeText(QString::fromStdString(_text));
userInput.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
userInput.button(QMessageBox::Ok)->setText("Allow");
userInput.button(QMessageBox::Cancel)->setText("Reject");
userInput.setDefaultButton(QMessageBox::Cancel);
return userInput.exec() == QMessageBox::Ok;
}
示例4: main
int main(int argc, char *argv[])
{
openstudio::Logger::instance().standardOutLogger().disable();
openstudio::FileLogSink logFile(openstudio::toPath(logfilepath));
logFile.setLogLevel(Warn);
bool cont = true;
while(cont) {
cont = false;
QApplication qApplication(argc,argv);
openstudio::Application::instance().setApplication(&qApplication);
try {
resultsviewer::MainWindow w;
w.show();
return qApplication.exec();
} catch (const std::exception &e) {
LOG_FREE(Fatal, "ResultsViewer", "An unhandled exception has occurred: " << e.what());
cont = true;
QMessageBox msgBox;
msgBox.setWindowTitle("Unhandled Exception");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("An unhandled exception has occurred.");
msgBox.setInformativeText(e.what());
msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
msgBox.button(QMessageBox::Retry)->setText("Relaunch");
if (msgBox.exec() == QMessageBox::Close) {
cont = false;
}
} catch (...) {
LOG_FREE(Fatal, "ResultsViewer", "An unknown exception has occurred.");
cont = true;
QMessageBox msgBox;
msgBox.setWindowTitle("Unknown Exception");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("An unknown exception has occurred.");
msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
msgBox.button(QMessageBox::Retry)->setText("Relaunch");
if (msgBox.exec() == QMessageBox::Close) {
cont = false;
}
}
}
}
示例5: saveFile
void
WorkoutWindow::ergFileSelected(ErgFile*f)
{
if (active) return;
if (workout->isDirty()) {
QMessageBox msgBox;
msgBox.setText(tr("You have unsaved changes to a workout."));
msgBox.setInformativeText(tr("Do you want to save them?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Cancel);
msgBox.setIcon(QMessageBox::Warning);
msgBox.exec();
// save first, otherwise changes lost
if(msgBox.clickedButton() == msgBox.button(QMessageBox::Yes)) {
active = true;
saveFile();
active = false;
}
}
// just get on with it.
ergFile = f;
workout->ergFileSelected(f);
// almost certainly hides it on load
setScroller(QPointF(workout->minVX(), workout->maxVX()));
}
示例6: confirmDeleteColorScheme
void FontSettingsPage::confirmDeleteColorScheme()
{
const int index = d_ptr->m_ui->schemeComboBox->currentIndex();
if (index == -1)
return;
const ColorSchemeEntry &entry = d_ptr->m_schemeListModel->colorSchemeAt(index);
if (entry.readOnly)
return;
QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
tr("Delete Color Scheme"),
tr("Are you sure you want to delete this color scheme permanently?"),
QMessageBox::Discard | QMessageBox::Cancel,
d_ptr->m_ui->deleteButton->window());
// Change the text and role of the discard button
auto deleteButton = static_cast<QPushButton*>(messageBox->button(QMessageBox::Discard));
deleteButton->setText(tr("Delete"));
messageBox->addButton(deleteButton, QMessageBox::AcceptRole);
messageBox->setDefaultButton(deleteButton);
connect(deleteButton, &QAbstractButton::clicked, messageBox, &QDialog::accept);
connect(messageBox, &QDialog::accepted, this, &FontSettingsPage::deleteColorScheme);
messageBox->setAttribute(Qt::WA_DeleteOnClose);
messageBox->open();
}
示例7: maybeSaveColorScheme
void FontSettingsPage::maybeSaveColorScheme()
{
if (d_ptr->m_value.colorScheme() == d_ptr->m_ui->schemeEdit->colorScheme())
return;
QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
tr("Color Scheme Changed"),
tr("The color scheme \"%1\" was modified, do you want to save the changes?")
.arg(d_ptr->m_ui->schemeEdit->colorScheme().displayName()),
QMessageBox::Discard | QMessageBox::Save,
d_ptr->m_ui->schemeComboBox->window());
// Change the text of the discard button
QPushButton *discardButton = static_cast<QPushButton*>(messageBox->button(QMessageBox::Discard));
discardButton->setText(tr("Discard"));
messageBox->addButton(discardButton, QMessageBox::DestructiveRole);
messageBox->setDefaultButton(QMessageBox::Save);
if (messageBox->exec() == QMessageBox::Save) {
const ColorScheme &scheme = d_ptr->m_ui->schemeEdit->colorScheme();
scheme.save(d_ptr->m_value.colorSchemeFileName(), Core::ICore::mainWindow());
}
}
示例8: maybeSaveTheme
void ThemeSettingsWidget::maybeSaveTheme()
{
if (!d->m_ui->editor->model()->hasChanges())
return;
QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
tr("Theme Changed"),
tr("The theme \"%1\" was modified, do you want to save the changes?")
.arg(d->m_currentTheme.displayName()),
QMessageBox::Discard | QMessageBox::Save,
d->m_ui->themeComboBox->window());
// Change the text of the discard button
QPushButton *discardButton = static_cast<QPushButton*>(messageBox->button(QMessageBox::Discard));
discardButton->setText(tr("Discard"));
messageBox->addButton(discardButton, QMessageBox::DestructiveRole);
messageBox->setDefaultButton(QMessageBox::Save);
if (messageBox->exec() == QMessageBox::Save) {
Theme newTheme(d->m_currentTheme.name());
d->m_ui->editor->model()->toTheme(&newTheme);
newTheme.writeSettings(d->m_currentTheme.filePath());
}
}
示例9: rx
void measurepulse::on_pushButton_7_clicked()
{
publiccaution.addevent("摩擦系数测试页面","完成测试并退出","用户完成测试并退出",1);
//校验上次的测试
QRegExp rx("^\\d+\\.?\\d*$");
if ( rx.indexIn(lineEdit[2]->text()) == -1)
{
QMessageBox msgBox;
msgBox.setText("输入格式不对,请重新输入");
msgBox.setWindowTitle("输入错误");
msgBox.setStandardButtons(QMessageBox::Yes );
QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
tb->setText("确定");
return;
}
bool ok;
if (lineEdit[2]->text().toDouble(&ok) == 0)
{
QMessageBox msgBox;
msgBox.setText("输入数据为0,请重新输入");
msgBox.setWindowTitle("输入错误");
msgBox.setStandardButtons(QMessageBox::Yes );
QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
tb->setText("确定");
msgBox.exec();
return;
}
double count = 0;
ksmc->GetEncoderCount(count);
//新值小于小于旧值,说明可能翻转了
if (count < encoder[2])
{
//真正翻转,而不是编码器回退,回退脉冲不可能超过3000000000
if (count < 1000000000 && encoder[2] > 4000000000)
{
encoder[2] = 4294967295 - encoder[2] + count;
}
else
{
encoder[2] = count - encoder[2];
}
}
else
{
encoder[2] = count - encoder[2];
}
//校验编码计数
if (encoder[2] == 0)
{
QMessageBox msgBox;
msgBox.setText("编码器计数没有变化,请重新测试");
msgBox.setWindowTitle("错误");
msgBox.setStandardButtons(QMessageBox::Yes );
QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
tb->setText("确定");
msgBox.exec();
ui.pushButton->setEnabled(false);
ui.pushButton_2->setEnabled(false);
ui.pushButton_3->setEnabled(false);
ui.pushButton_4->setEnabled(false);
ui.pushButton_5->setEnabled(true);
ui.pushButton_6->setEnabled(false);
ui.pushButton_7->setEnabled(false);
lineEdit[0]->setEnabled(false);
lineEdit[1]->setEnabled(false);
lineEdit[2]->setEnabled(false);
lineEdit[2]->clear();
//返回
return;
}
//3次的摩擦系数校验
//一致性标识
bool validcheck = true;
meaure[0] = lineEdit[0]->text().toDouble(&ok);
meaure[1] = lineEdit[1]->text().toDouble(&ok);
meaure[2] = lineEdit[2]->text().toDouble(&ok);
double frications[3];
for (int i = 0;i < 3; ++i)
{
if (meaure[i] != 0)
{
frications[i] = encoder[i] / meaure[i];
std::cout << "encoder,measure,frication:" << encoder[i] << "," << meaure[i] << "," << frications[i];
}
else
{
//.........这里部分代码省略.........
示例10: CHECK_DELETE_LINE
int MUH_HESAP_EKLEME_FISI::CHECK_DELETE_LINE ( int fis_id, int row_number )
{
Q_UNUSED(fis_id);
m_hesabin_parentini_aktar = false;
int alt_hesap_sayisi = 0;
int parent_id = 0;
int hesap_id = m_ui->tablewidget_alt_hesaplar->item ( row_number, ROW_ID_COLUMN )->text().toInt();
QMessageBox * mesaj = new QMessageBox ( this );
mesaj->setButtonText ( QMessageBox::Ok, tr ("Devam") );
QPushButton * buton_cancel = mesaj->addButton ( QMessageBox::Cancel );
mesaj->setButtonText ( QMessageBox::Cancel, tr ( "Vazgeç" ) );
SQL_QUERY sql_query ( DB );
sql_query.PREPARE_SELECT("muh_hesaplar" , "tam_hesap_kodu , hesap_ismi" , "hesap_id = :hesap_id");
sql_query.SET_VALUE ( ":hesap_id", hesap_id );
if ( sql_query.SELECT() NE 0 ) {
sql_query.NEXT();
mesaj->setWindowTitle ( tr ( "DİKKAT" ) );
mesaj->setText ( tr ( "'%1 %2'` hesabı silinecek." ).arg ( sql_query.VALUE(0).toString()).arg ( sql_query.VALUE(1).toString() ) );
mesaj->setInformativeText ( "Emin misiniz?" );
mesaj->exec();
if (mesaj->clickedButton() EQ buton_cancel ) {
return ADAK_FAIL;
}
}
sql_query.PREPARE_SELECT("muh_hesaplar" , "hesap_id" , "parent_id = :parent_id");
sql_query.SET_VALUE ( ":parent_id", hesap_id );
alt_hesap_sayisi = sql_query.SELECT();
if ( alt_hesap_sayisi > 0 ) {
mesaj->setText ( tr ( "Hesabı silmek için,önce alt hesaplarını silmelisiniz!.." ) );
mesaj->removeButton ( mesaj->button ( QMessageBox::Cancel ) );
mesaj->setInformativeText ( "" );
mesaj->setButtonText ( QMessageBox::Ok, tr ( "Tamam" ) );
mesaj->exec();
return ADAK_FAIL;
}
//Hesabin tek bir alt hesabi varsa,alt hesap ile ana hesap yer degistirecek
sql_query.PREPARE_SELECT("muh_hesaplar" , "parent_id" , "hesap_id = :hesap_id");
sql_query.SET_VALUE ( ":hesap_id", hesap_id );
if ( sql_query.SELECT() NE 0 ) {
sql_query.NEXT();
parent_id = sql_query.VALUE(0).toInt();
}
sql_query.PREPARE_SELECT("muh_hesaplar" , "hesap_id" , "parent_id = :parent_id");
sql_query.SET_VALUE ( ":parent_id", parent_id );
if ( sql_query.SELECT() NE 0 ) {
int hesap_sayisi = sql_query.NUM_OF_ROWS();
if ( hesap_sayisi EQ 1 ) {
m_hesabin_parentini_aktar = true;
return ADAK_OK;
}
sql_query.PREPARE_SELECT("muh_fis_satirlari" , "fis_id" , "hesap_id = :hesap_id");
sql_query.SET_VALUE(":hesap_id" , hesap_id);
if ( sql_query.SELECT() NE 0 ) {
DB->CANCEL_TRANSACTION();
mesaj = new QMessageBox();
mesaj->setIcon ( QMessageBox::Critical );
mesaj->setWindowTitle ( tr ( "HATA" ) );
mesaj->addButton ( QMessageBox::Ok );
mesaj->setText ( tr ( "Hesap işlem görmüş,silinemez!.." ) );
mesaj->exec();
return ADAK_FAIL;
}
}
return ADAK_OK;
}
示例11: main
int main(int argc, char *argv[])
{
ruby_sysinit(&argc, &argv);
{
RUBY_INIT_STACK;
ruby_init();
}
#if _DEBUG || (__GNUC__ && !NDEBUG)
#ifdef _WIN32
const char *logfilepath = "./openstudio_pat.log";
#else
const char *logfilepath = "/var/log/openstudio_pat.log";
#endif
openstudio::Logger::instance().standardOutLogger().setLogLevel(Debug);
openstudio::FileLogSink fileLog(openstudio::toPath(logfilepath));
fileLog.setLogLevel(Debug);
#else
openstudio::Logger::instance().standardOutLogger().setLogLevel(Warn);
#endif
// list of Ruby modules we want to load into the interpreter
std::vector<std::string> modules;
modules.push_back("openstudioutilitiescore");
modules.push_back("openstudioutilitiesbcl");
modules.push_back("openstudioutilitiesidd");
modules.push_back("openstudioutilitiesidf");
modules.push_back("openstudioutilities");
modules.push_back("openstudiomodel");
modules.push_back("openstudiomodelcore");
modules.push_back("openstudiomodelsimulation");
modules.push_back("openstudiomodelresources");
modules.push_back("openstudiomodelgeometry");
modules.push_back("openstudiomodelhvac");
modules.push_back("openstudiomodelrefrigeration");
modules.push_back("openstudioenergyplus");
modules.push_back("openstudioruleset");
bool cont = true;
while(cont) {
cont = false;
// Initialize the embedded Ruby interpreter
std::shared_ptr<openstudio::detail::RubyInterpreter> rubyInterpreter(
new openstudio::detail::RubyInterpreter(openstudio::getOpenStudioRubyPath(),
openstudio::getOpenStudioRubyScriptsPath(),
modules));
// Initialize the argument getter
QSharedPointer<openstudio::ruleset::RubyUserScriptInfoGetter> infoGetter(
new openstudio::ruleset::EmbeddedRubyUserScriptInfoGetter<openstudio::detail::RubyInterpreter>(rubyInterpreter));
// Make the run path the default plugin search location
QCoreApplication::addLibraryPath(openstudio::toQString(openstudio::getApplicationRunDirectory()));
openstudio::pat::PatApp app(argc, argv, infoGetter);
openstudio::Application::instance().setApplication(&app);
try {
return app.exec();
} catch (const std::exception &e) {
LOG_FREE(Fatal, "PatApp", "An unhandled exception has occurred: " << e.what());
cont = true;
QMessageBox msgBox;
msgBox.setWindowTitle("Unhandled Exception");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("An unhandled exception has occurred.");
msgBox.setInformativeText(e.what());
msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
msgBox.button(QMessageBox::Retry)->setText("Relaunch");
if (msgBox.exec() == QMessageBox::Close) {
cont = false;
}
} catch (...) {
LOG_FREE(Fatal, "PatApp", "An unknown exception has occurred.");
cont = true;
QMessageBox msgBox;
msgBox.setWindowTitle("Unknown Exception");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("An unknown exception has occurred.");
msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
msgBox.button(QMessageBox::Retry)->setText("Relaunch");
if (msgBox.exec() == QMessageBox::Close) {
cont = false;
}
}
}
}
示例12: Open
//打开串口设备
bool Open(struct serialif* pserialif)
{
pserialif->devmutex.lock();
//设置并打开端口
pserialif->hCom = CreateFileA(pserialif->Name.toAscii(), GENERIC_READ
| GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if (pserialif->hCom == (HANDLE) - 1)
{
QMessageBox msgBox;
msgBox.setText("没有检测到加密狗!");
msgBox.setWindowTitle("错误");
msgBox.setStandardButtons(QMessageBox::Yes );
QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
tb->setText("确定");
msgBox.exec();
}
else
{
DCB wdcb;
GetCommState(pserialif->hCom, &wdcb);
wdcb.BaudRate = pserialif->BaudRate.toUInt();
wdcb.ByteSize = pserialif->ByteSize.toUInt();
if (pserialif->Parity == QString("EVEN"))
{
wdcb.Parity = EVENPARITY;
}
else if(pserialif->Parity == QString("ODD"))
{
wdcb.Parity = ODDPARITY;
}
else
{
wdcb.Parity = NOPARITY;
}
if (pserialif->StopBits == QString("2"))
{
wdcb.StopBits =TWOSTOPBITS;
}
else
{
wdcb.StopBits =ONESTOPBIT;
}
if (pserialif->fRtsControl == QString("disable"))
{
wdcb.fRtsControl = RTS_CONTROL_DISABLE;
}
else if(pserialif->fRtsControl == QString("handshake"))
{
wdcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
}
else if(pserialif->fRtsControl == QString("toggle"))
{
wdcb.fRtsControl = RTS_CONTROL_TOGGLE;
}
else
{
wdcb.fRtsControl = RTS_CONTROL_ENABLE;
}
SetCommState(pserialif->hCom, &wdcb);
PurgeComm(pserialif->hCom, PURGE_TXCLEAR|PURGE_RXCLEAR);
//异步要设置超时时间
COMMTIMEOUTS m_timeout;
m_timeout.ReadIntervalTimeout = 1000;
m_timeout.ReadTotalTimeoutConstant = 1000;
m_timeout.ReadTotalTimeoutMultiplier = 1000;
m_timeout.WriteTotalTimeoutConstant = 1000;
m_timeout.WriteTotalTimeoutMultiplier =1000;
SetCommTimeouts(pserialif->hCom,&m_timeout);
pserialif->deviceopen = true;
}
pserialif->devmutex.unlock();
return true;
}
示例13: main
int main(int argc, char *argv[])
{
#if RUBY_API_VERSION_MAJOR && RUBY_API_VERSION_MAJOR==2
ruby_sysinit(&argc, &argv);
{
RUBY_INIT_STACK;
ruby_init();
}
#endif
#if _DEBUG || (__GNUC__ && !NDEBUG)
openstudio::Logger::instance().standardOutLogger().setLogLevel(Debug);
openstudio::FileLogSink fileLog(openstudio::toPath(logfilepath));
fileLog.setLogLevel(Debug);
#else
openstudio::Logger::instance().standardOutLogger().setLogLevel(Warn);
#endif
bool cont = true;
while(cont) {
cont = false;
std::vector<std::string> modules;
modules.push_back("openstudioutilitiescore");
modules.push_back("openstudioutilitiesbcl");
modules.push_back("openstudioutilitiesidd");
modules.push_back("openstudioutilitiesidf");
modules.push_back("openstudioutilities");
modules.push_back("openstudiomodel");
modules.push_back("openstudiomodelcore");
modules.push_back("openstudiomodelsimulation");
modules.push_back("openstudiomodelresources");
modules.push_back("openstudiomodelgeometry");
modules.push_back("openstudiomodelhvac");
modules.push_back("openstudioenergyplus");
modules.push_back("openstudioruleset");
//try {
// Initialize the embedded Ruby interpreter
boost::shared_ptr<openstudio::detail::RubyInterpreter> rubyInterpreter(
new openstudio::detail::RubyInterpreter(openstudio::getOpenStudioRubyPath(),
openstudio::getOpenStudioRubyScriptsPath(),
modules));
// Initialize the argument getter
QSharedPointer<openstudio::ruleset::RubyUserScriptArgumentGetter> argumentGetter(
new openstudio::ruleset::detail::RubyUserScriptArgumentGetter_Impl<openstudio::detail::RubyInterpreter>(rubyInterpreter));
openstudio::OpenStudioApp app(argc, argv, argumentGetter);
openstudio::Application::instance().setApplication(&app);
try {
return app.exec();
} catch (const std::exception &e) {
LOG_FREE(Fatal, "OpenStudio", "An unhandled exception has occurred: " << e.what());
cont = true;
QMessageBox msgBox;
msgBox.setWindowTitle("Unhandled Exception");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("An unhandled exception has occurred.");
msgBox.setInformativeText(e.what());
msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
msgBox.button(QMessageBox::Retry)->setText("Relaunch");
if (msgBox.exec() == QMessageBox::Close) {
cont = false;
}
} catch (...) {
LOG_FREE(Fatal, "OpenStudio", "An unknown exception has occurred.");
cont = true;
QMessageBox msgBox;
msgBox.setWindowTitle("Unknown Exception");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("An unknown exception has occurred.");
msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
msgBox.button(QMessageBox::Retry)->setText("Relaunch");
if (msgBox.exec() == QMessageBox::Close) {
cont = false;
}
}
}
}
示例14: onFeaturePermissionRequest
void WebView::onFeaturePermissionRequest(const QUrl &securityOrigin, QWebEnginePage::Feature feature)
{
if(Preferences::getInstance()->isPermissionGranted(feature))
{
page()->setFeaturePermission(securityOrigin, feature, QWebEnginePage::PermissionGrantedByUser);
return;
}
if(Preferences::getInstance()->isPermissionDenied(feature))
{
page()->setFeaturePermission(securityOrigin, feature, QWebEnginePage::PermissionDeniedByUser);
return;
}
auto permissionString = [](QWebEnginePage::Feature feature) {
switch(feature)
{
case QWebEnginePage::Geolocation:
return tr("current location");
case QWebEnginePage::MediaAudioVideoCapture:
return tr("camera and microphone");
case QWebEnginePage::MediaAudioCapture:
return tr("microphone");
case QWebEnginePage::MediaVideoCapture:
return tr("camera");
default:
return tr("unknown");
}
};
qDebug() << Q_FUNC_INFO;
qDebug() << securityOrigin << " " << feature;
QMessageBox *box = new QMessageBox(QMessageBox::Question,
tr("Permission Request"),
tr("VRSteam wants to access your %1, do you want to allow that?").arg(permissionString(feature)),
QMessageBox::Yes | QMessageBox::No,
this);
QCheckBox *checkBox = new QCheckBox(tr("Remember this decision"), box);
box->setCheckBox(checkBox);
box->exec();
bool accepted = box->clickedButton() == box->button(QMessageBox::Yes);
if(accepted)
{
qDebug() << "Accepted feature request";
page()->setFeaturePermission(securityOrigin, feature, QWebEnginePage::PermissionGrantedByUser);
}
else
{
qDebug() << "Denied feature request";
page()->setFeaturePermission(securityOrigin, feature, QWebEnginePage::PermissionDeniedByUser);
}
if(checkBox->isChecked())
{
Preferences::getInstance()->setPermission(feature, accepted);
}
}
示例15: checkSystemInstallation
bool checkSystemInstallation(QString& parVboxDefaultMachineFolder)
{
QString buttonContinueText = QCoreApplication::translate("'Continue-anyway'-Button of a shown warning", "Continue anyway");
size_t memorySize = getMemorySize( );
qint64 freeMemoryInMb = memorySize / (1024 * 1024);
// currently not needed:
//ILOG("Total Physical RAM size: " + QString::number(freeMemoryInMb) + " MB");
//qint64 freeSpace = getFreeDiskSpace(parInstallPath);
//ILOG("Free space on disk containing '" + parInstallPath + "': " + QString::number(freeSpace) + " Bytes");
int availableRamNeededInMB;
if (RunningOnWindows())
availableRamNeededInMB = 1024 * 3;
else
availableRamNeededInMB = 1024 * 2;
if (freeMemoryInMb < availableRamNeededInMB)
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(QApplication::applicationName()+" "+QApplication::applicationVersion());
QString message = QCoreApplication::translate("check available resources", "This computer has to low memory(%1 MegaByte) for the PrivacyMachine to work properly (highly recommended: %2 MegaByte).");
message = message.arg(QString::number(freeMemoryInMb), QString::number(availableRamNeededInMB));
msgBox.setStandardButtons(QMessageBox::Abort | QMessageBox::Ignore);
msgBox.button(QMessageBox::Ignore)->setText(buttonContinueText);
msgBox.setText(message);
int ret = msgBox.exec();
if (ret != QMessageBox::Ignore)
return false;
else
ILOG("User pressed Button 'Continue Anyway' while memory check");
}
bool hasVirtualization = CpuFeatures::Virtualization();
if (!hasVirtualization)
{
IERR("Hardware Virtualisation Support is not available");
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setWindowTitle(QApplication::applicationName()+" "+QApplication::applicationVersion());
msgBox.setTextFormat(Qt::RichText); // this is what makes the links clickable
QString message = QCoreApplication::translate("check available resources", "The Hardware Virtualization Support for the CPU is not enabled (or does not exist on very old computers). Please reboot to enter your BIOS and enable an option called like Virtualization, VT-x, AMD-V or AMD-SVM");
message += "<br>";
message += "<div style=\"text-align:center\">";
message += "<a href='http://www.howtogeek.com/213795/how-to-enable-intel-vt-x-in-your-computers-bios-or-uefi-firmware/'>Explanation on howtogeek.com</a>";
message += "</div>";
msgBox.setText(message);
msgBox.exec();
return false;
}
bool vboxInstalled;
QString vboxCommand;
QString vboxVersion;
bool vboxExtensionPackInstalled;
determineVirtualBoxInstallation(vboxInstalled, vboxCommand, vboxVersion, parVboxDefaultMachineFolder, vboxExtensionPackInstalled);
if (!vboxInstalled)
{
IERR("VirtualBox is not installed");
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setWindowTitle(QApplication::applicationName()+" "+QApplication::applicationVersion());
msgBox.setTextFormat(Qt::RichText); // this is what makes the links clickable
QString message = QCoreApplication::translate("check of software dependencies", "VirtualBox from Oracle is not installed, please download it directly from:");
message += "<br>";
message += "<div style=\"text-align:center\">";
message += "<a href='https://www.virtualbox.org'>https://www.virtualbox.org</a>";
message += "</div>";
msgBox.setText(message);
msgBox.exec();
return false;
}
if (!vboxExtensionPackInstalled)
{
IERR("ExtensionPack of VirtualBox is not installed");
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setWindowTitle(QApplication::applicationName()+" "+QApplication::applicationVersion());
msgBox.setTextFormat(Qt::RichText); // this is what makes the links clickable
QString messagePart1 = QCoreApplication::translate("check of software dependencies", "The 'Extension Pack' for VirtualBox is not installed, please download it directly from:");
messagePart1 += "<br>";
messagePart1 += "<div style=\"text-align:center\">";
messagePart1 += "<a href='https://www.virtualbox.org/wiki/Downloads'>https://www.virtualbox.org/wiki/Downloads</a>";
messagePart1 += "</div>";
QString messagePart2 = QCoreApplication::translate("check of software dependencies", "Install the downloaded File 'Oracle_VM_VirtualBox_Extension_Pack-[CurrentVersion].vbox-extpack' with a Double-Click (it will be opened by VirtualBox)");
msgBox.setText(messagePart1 + "<br><br>" + messagePart2);
msgBox.exec();
return false;
}
// We only support the VirtualBox-Versions supported by Oracle: One main and one legacy version
// @Debian-Users: Sorry, but VirtualBox is not maintained any more: <https://www.debian.org/security/2016/dsa-3699>
//
// from <https://www.virtualbox.org/wiki/Download_Old_Builds>
// i.e. Actual Version of VirtualBox-Stable : 5.0.28 (<StableMajor>.<StableMinor>.<StableBugfix>)
// i.e. Actual Version of VirtualBox-Current: 5.1.8 (<CurrentMajor>.<CurrentMinor>.<CurrentBugfix>)
// -> 5.0.28: ok
//.........这里部分代码省略.........