/* *点击“关于”执行此函数 *弹出对话框 */ void Game_main::about() { QDialog *Dblack = new QDialog(); QVBoxLayout *vlayout = new QVBoxLayout; Dblack->setFixedSize(300,280); QLabel *label = new QLabel("Copy Right @ UESTC-CCSE wytk2008.net"); QAbstractButton *bExit = new QPushButton("back"); vlayout->addWidget(label); vlayout->addWidget(bExit); Dblack->setLayout(vlayout); Dblack->show(); Dblack->connect(bExit,SIGNAL(clicked()),Dblack,SLOT(close())); }
void VcsEventWidgetPrivate::diffToPrevious() { KDevelop::VcsEvent ev = m_logModel->eventForIndex( m_contextIndex ); KDevelop::VcsRevision prev = KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Previous); KDevelop::VcsJob* job = m_iface->diff( m_url, prev, ev.revision() ); VcsDiffWidget* widget = new VcsDiffWidget( job ); widget->setRevisions( prev, ev.revision() ); QDialog* dlg = new QDialog( q ); widget->connect(widget, &VcsDiffWidget::destroyed, dlg, &QDialog::deleteLater); dlg->setWindowTitle( i18n("Difference To Previous") ); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); auto mainWidget = new QWidget; QVBoxLayout *mainLayout = new QVBoxLayout; dlg->setLayout(mainLayout); mainLayout->addWidget(mainWidget); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); dlg->connect(buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept); dlg->connect(buttonBox, &QDialogButtonBox::rejected, dlg, &QDialog::reject); mainLayout->addWidget(widget); mainLayout->addWidget(buttonBox); dlg->show(); }
void Game_main::whoWin()//直接判断white_win,black_win弹出窗口 { if(white_win) { QDialog *Dblack = new QDialog(); QVBoxLayout *vlayout = new QVBoxLayout; Dblack->setFixedSize(150,140); QLabel *label = new QLabel("白棋胜利!"); QAbstractButton *bExit = new QPushButton("再来一局"); bExit->setText("再来一局"); vlayout->addWidget(label); vlayout->addWidget(bExit); Dblack->setLayout(vlayout); Dblack->show(); Dblack->connect(bExit,SIGNAL(clicked()),Dblack,SLOT(close())); Dblack->connect(bExit,SIGNAL(clicked()),this,SLOT(start())); is_over = true; } if(black_win) { QDialog *Dblack = new QDialog(); QVBoxLayout *vlayout = new QVBoxLayout; Dblack->setFixedSize(150,140); QLabel *label = new QLabel("黑棋胜利!"); QAbstractButton *bExit = new QPushButton("再来一局"); bExit->setText("再来一局"); vlayout->addWidget(label); vlayout->addWidget(bExit); Dblack->setLayout(vlayout); Dblack->show(); Dblack->connect(bExit,SIGNAL(clicked()),Dblack,SLOT(close())); Dblack->connect(bExit,SIGNAL(clicked()),this,SLOT(start())); is_over =true; } }
CrashHandler::Action CrashHandler::promptUserForAction(bool showCrashMessage) { QDialog crashDialog; QLabel* label; if (showCrashMessage) { crashDialog.setWindowTitle("Interface Crashed Last Run"); label = new QLabel("If you are having trouble starting would you like to reset your settings?"); } else { crashDialog.setWindowTitle("Reset Settings"); label = new QLabel("Would you like to reset your settings?"); } QVBoxLayout* layout = new QVBoxLayout; layout->addWidget(label); QRadioButton* option1 = new QRadioButton("Reset all my settings"); QRadioButton* option2 = new QRadioButton("Reset my settings but keep essential info"); QRadioButton* option3 = new QRadioButton("Continue with my current settings"); option3->setChecked(true); layout->addWidget(option1); layout->addWidget(option2); layout->addWidget(option3); layout->addSpacing(12); layout->addStretch(); QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok); layout->addWidget(buttons); crashDialog.connect(buttons, SIGNAL(accepted()), SLOT(accept())); crashDialog.setLayout(layout); int result = crashDialog.exec(); if (result == QDialog::Accepted) { if (option1->isChecked()) { return CrashHandler::DELETE_INTERFACE_INI; } if (option2->isChecked()) { return CrashHandler::RETAIN_IMPORTANT_INFO; } } // Dialog cancelled or "do nothing" option chosen return CrashHandler::DO_NOTHING; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QApplication::setOrganizationName(_S("Majister")); QApplication::setApplicationName(_S("jPos")); qRegisterMetaType<SyncState>("SyncState"); // Имя файла логов logFileName.clear(); // Настройки базы - SQLite QString mainBase = _S("db.sqlite3"); QString dbDriver = _S("QSQLITE"); QString dbUser; QString dbPass; QString dbOptions; QString executeModule; QString executeParams; QString styleFileName; bool stylefree = false; // Уровни лога, 1- только ошибки, 2 - основные действия, 3 - отладка каждого чиха int loglevel = 1; // Обнулить файл логов bool newlog = false; bool resetSettings = false; bool showHelp = false; bool saveSources = false; QStringList args = QCoreApplication::arguments(); for (int i = 1; i < args.count(); ++i) { QString value = args.at(i); if (value == _S("--logfile") && i < args.count()) { logFileName = args.at(++i); continue; } if (value == _S("--loglevel") && i < args.count()) { loglevel = args.at(++i).toInt(); continue; } if (value == _S("--newlog")) { newlog = true; continue; } if (value == _S("--driver") && i < args.count()) { dbDriver = args.at(++i); continue; } if (value == _S("--user") && i < args.count()) { dbUser = args.at(++i); continue; } if (value == _S("--password") && i < args.count()) { dbPass = args.at(++i); continue; } if (value == _S("--resetsettings")) { resetSettings = true; continue; } if (value == _S("--stylefree")) { stylefree = true; continue; } if (value == _S("--istyle") && i < args.count()) { styleFileName = args.at(++i); continue; } if (value == _S("--version")) { qDebug() << _T("jPOS версия от %1 %2").arg(BUILDDATE).arg(BUILDTIME); return 0; } if (value == _S("--help")) { showHelp = true; break; // all other params not matter } if (value == _S("--sources")) { saveSources = true; break; // all other params not matter } if (value == _S("--execute") && i+1 < args.count()) { executeModule = args.at(++i); executeParams = args.at(++i); continue; } // если не параметров - значит название базы mainBase = value; } if (saveSources) { QFile sourcesFile(_S(":/sources/sources/sources.7z")); if(!sourcesFile.open(QFile::ReadOnly)) { qDebug() << _T("%1 Ошибка доступа к исходникам: %2") .arg(posForLog) .arg(sourcesFile.errorString()); return 1; } QFile resultFile(_S("sources.7z")); if(!resultFile.open(QFile::WriteOnly)) { qDebug() << _T("%1 Ошибка создания файла для сохранения: %2") .arg(posForLog) .arg(resultFile.errorString()); return 1; } resultFile.write(sourcesFile.readAll()); resultFile.close(); sourcesFile.close(); qDebug()<<"Исходники сохранены в файле sources.7z"; return 0; } if (showHelp) { QFile helpFile(_S(":/texts/texts/help.txt")); helpFile.open(QFile::ReadOnly); QString helpText = helpFile.readAll(); qDebug() << _T("jPOS версия от %1 %2").arg(BUILDDATE).arg(BUILDTIME)<<endl; qDebug() << helpText; return 0; } if (newlog) { QFile::remove(logFileName); } if (!logFileName.isEmpty()) qInstallMessageHandler(fileMessageHandler); //else // qInstallMessageHandler(outputMessageHandler); if(!stylefree) { QFile styleFile; if(!styleFileName.isEmpty()) styleFile.setFileName(styleFileName); else styleFile.setFileName(":/qss/qss/black-n-orange.qss"); styleFile.open(QFile::ReadOnly); QString styleSheet = QString::fromLatin1(styleFile.readAll()); qApp->setStyleSheet(styleSheet); } Datapipe * data = new Datapipe(); QMap<QString, QVariant>* vars = data->getVariables(); if (loglevel > 0) qDebug() << _T("%1 Уровень лога: %2").arg(posForLog).arg(loglevel); vars->insert(_S("loglevel"), loglevel); QSettings *settings = data->getSettings(); if (resetSettings) settings->clear(); QStringList settingsKeys = settings->allKeys(); QSettings *defaults = new QSettings(_S(":/defaults/defaults/globalsettings.ini"), QSettings::IniFormat); defaults->setIniCodec(QTextCodec::codecForName("UTF-8")); QStringList defaultKeys = defaults->allKeys(); for (int i = 0; i < defaultKeys.count(); i++) { QString key = defaultKeys.at(i); QVariant value = defaults->value(key); if (!settingsKeys.contains(key)) settings->setValue(key, value); } delete defaults; QFont font; font.setFamily(settings->value("global/default_font","DejaVu Sans").toString()); font.setPixelSize(settings->value("global/default_font_size",14).toInt()); font.setBold(settings->value("global/defalut_font_bold",true).toBool()); qApp->setFont(font); // Финт - зададим дефолты для некоторых баз if((dbDriver=="QIBASE" || dbDriver=="QFIREBIRD") && dbUser.isEmpty()) dbUser="******"; if((dbDriver=="QIBASE" || dbDriver=="QFIREBIRD") && dbPass.isEmpty()) dbPass="******"; QSqlDatabase db = QSqlDatabase::addDatabase(dbDriver); db.setDatabaseName(mainBase); db.setUserName(dbUser); db.setPassword(dbPass); db.setConnectOptions(dbOptions); if (!db.open()) { qCritical()<<_T("%1 Ошибка подключения: %2").arg(posForLog).arg(db.lastError().text()); return 2; } if (loglevel > 0) { qDebug() << _T("%1 База данных: %2").arg(posForLog).arg(mainBase); qDebug() << _T("%1 Драйвер: %2").arg(posForLog).arg(dbDriver); qDebug() << _T("%1 Пользователь: %2").arg(posForLog).arg(dbUser); qDebug() << _T("%1 Пароль: %2").arg(posForLog).arg(dbPass); qDebug() << _T("%1 Настройки: %2").arg(posForLog).arg(dbOptions); } vars->insert(_S("database"), mainBase); vars->insert(_S("database_driver"), dbDriver); vars->insert(_S("database_user"), dbUser); vars->insert(_S("database_password"), dbPass); vars->insert(_S("database_settings"), dbOptions); QSqlQuery query; query.prepare(settings->value(_S("global/queries/settings")).toString()); if (query.exec()) { while (query.next()) { vars->insert(query.value(0).toString(), query.value(1)); if(loglevel > 0) qDebug() << _T("%1 Переменные: %2 = %3").arg(posForLog).arg(query.value(0).toString()).arg(query.value(1).toString()); } } else { bool solved = false; if(dbDriver=="QSQLITE") { QMessageBox::StandardButton reply; reply = QMessageBox::question(0, _T("Не обнаружена база данных"), _T("Не обнаружена база данных\nСоздать новую?"), QMessageBox::Yes|QMessageBox::No); if (reply == QMessageBox::Yes) { QFile file(":/defaults/defaults/database_sqlite.sql"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qCritical() << _T("%1 Ошибка создания новой базы данных\n%2").arg(posForLog).arg(file.errorString()); return 0; } QStringList queryPartsList = QString::fromUtf8(file.readAll()).split(QRegExp("\\s"), QString::SkipEmptyParts); int triggerDepth=0; int stringDepth=0; bool skipOneBegin=false; QString queryFromParts; for(int i=0; i<queryPartsList.count();++i) { QString part = queryPartsList.at(i).trimmed(); if(part.isEmpty()) continue; if(part.toUpper() == "CREATE" && i+1 < queryPartsList.count()) if(queryPartsList.at(i+1)=="TRIGGER") { triggerDepth++; skipOneBegin=true; } if(triggerDepth > 0 && part.toUpper()=="BEGIN") { if(skipOneBegin) skipOneBegin=false; else triggerDepth++; } if(triggerDepth > 0 && part.toUpper()=="CASE") triggerDepth++; if(triggerDepth > 0 && part.toUpper().startsWith("END")) triggerDepth--; queryFromParts += _S(" %1").arg(part); //qDebug()<<part<<triggerDepth<<stringDepth; if(part.contains(";") && triggerDepth==0 && stringDepth==0) { bool skipQuery = false; if(queryFromParts.contains("CREATE TABLE sqlite_sequence")) skipQuery=true; if(queryFromParts.trimmed().isEmpty()) skipQuery=true; if(queryFromParts.trimmed()==";") skipQuery=true; if(!skipQuery) { if (!query.exec(queryFromParts)) { qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery()); return 1; } // qDebug()<<queryFromParts; } queryFromParts.clear(); } } QDialog dlg; QFormLayout layout; dlg.setLayout(&layout); QLineEdit posID; layout.addRow(_T("Код ПОС-а"), &posID); QLineEdit generatorMin; layout.addRow(_T("Генератор мин"), &generatorMin); QLineEdit generatorMax; layout.addRow(_T("Генератор макс"), &generatorMax); QPushButton bt; bt.setText("OK"); layout.addRow(0, &bt); dlg.connect(&bt, SIGNAL(clicked()), &dlg, SLOT(accept())); if(dlg.exec()==QDialog::Accepted) { query.prepare(settings->value(_S("global/queries/set_pos_id")).toString()); query.bindValue(":val", posID.text().toInt()); if(!query.exec()) { qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery()); return 1; } query.prepare(settings->value(_S("global/queries/set_generator_min")).toString()); query.bindValue(":val", generatorMin.text().toInt()); if(!query.exec()) { qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery()); return 1; } query.prepare(settings->value(_S("global/queries/set_generator_min1_sqlite")).toString()); query.bindValue(":val", generatorMin.text().toInt()); if(!query.exec()) { qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery()); return 1; } query.prepare(settings->value(_S("global/queries/set_generator_min2_sqlite")).toString()); query.bindValue(":val", generatorMin.text().toInt()); if(!query.exec()) { qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery()); return 1; } query.prepare(settings->value(_S("global/queries/set_generator_max")).toString()); query.bindValue(":val", generatorMax.text().toInt()); if(!query.exec()) { qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery()); return 1; } } else { QMessageBox message; message.setText(_T("Создание новой базы данных отменено")); message.exec(); return 1; } solved = true; } } if(!solved){ qCritical() << _T("%1 Ошибка чтения настроек\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery()); return 1; } } int width = 0; int height = 0; if (QApplication::desktop()->screenGeometry().width() > QApplication::desktop()->screenGeometry().height()) { width = QApplication::desktop()->screenGeometry().width(); height = QApplication::desktop()->screenGeometry().height(); } else { width = QApplication::desktop()->screenGeometry().height(); height = QApplication::desktop()->screenGeometry().width(); } double scale = settings->value("global/button_scale", 1).toDouble(); vars->insert(_S("standart_button_width"), (int) width / 12 * scale); vars->insert(_S("standart_button_height"), (int) height / 12 * scale); vars->insert(_S("standart_text_height"), (int) height / 18 * scale); vars->insert(_S("standart_margins"), (int) vars->value(_S("standart_button_width")).toInt() * 0.1 * scale); // заполняем тут, чтобы не тянуть в плагины все файлы data->setPrinter(new ChequePrinter(data->getSettings(), data->getVariables())); if (loglevel > 0) { QStringList keys = settings->allKeys(); for (int i = 0; i < keys.count(); i++) qDebug() << _T("%1 Настройки: %2 %3").arg(posForLog).arg(keys.at(i)).arg(settings->value(keys.at(i)).toString()); } if (loglevel > 0) qDebug() << _T("%1 Запуск ").arg(posForLog); MainWindow window(data); window.showFullScreen(); // проверка 3 return a.exec(); }
void ProfileDataInfoDialog::about_variables() { QDialog *dialog = new QDialog(this); dialog->resize(QSize(700, 480)); dialog->setWindowTitle(i18n("Usable Variables For Text Template")); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); dialog->connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); dialog->connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); QTextBrowser *tb = new QTextBrowser(dialog); tb->setHtml(i18n("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">" "<html>" "<head>" "<style type=\"text/css\">" "p, li { white-space: pre-wrap; }" "</style>" "</head>" "<body>" "Variables will be replaced by a special value and can even contain parameters.<br />" "For example the variable " "<div style=\"font-family:monospace; background: #b3c1d6; color: black\"><pre>" "$artist" "</pre></div>" "or the equivalent" "<div style=\"font-family:monospace; background: #b3c1d6; color: black\"><pre>" "${artist}" "</pre></div>" "will be replaced by the relevant artist of the cd. Variables may also have attribute, for example:" "<div style=\"font-family:monospace; background: #b3c1d6; color: black\"><pre>" "${today format=\"yyyy-MM-dd\"}" "</pre></div>" "This would print the current date. Setting the format will control how this is done. The example (above)" "would result int the date being printed as 2010-10-07 (if this was the current date). See below for more details.<br /><br />" "You can make use of the following variables:<br />" "<table border=1>" "<thead>" "<tr>" "<th>Variable</th><th>Parameter</th><th>Description</th><th>Example</th>" "</tr>" "</thead>" "<tbody>" "<tr>" "<td>$artist</td><td></td><td>Prints the relevant artist of the extracted cd.</td><td>${artist }</td>" "</tr>" "<tr>" "<td>$title</td><td></td><td>Prints the relevant title of the extracted cd.</td><td></td>" "</tr>" "<tr>" "<td>$date</td><td></td><td>Prints the relevant date (usually release year) of the extracted cd.</td><td></td>" "</tr>" "<tr>" "<td>$genre;</td><td></td><td>Prints the relevant genre of the extracted cd.</td><td></td>" "</tr>" "<tr>" "<td>$size</td><td>iec,precision</td><td>Prints the overall size of all extracted (compressed) music files (incl. the cover). The attribute iec can be one of the following: b, k, m, g. b means byte, k KiB, m MiB and g GiB. The attribute precision gives the number of decimal places. Default attributes are iec=\"m\" and precision=\"2\"</td><td>${size iec=\"k\" precision=\"2\"}</td>" "</tr>" "<tr>" "<td>$length</td><td></td><td>Prints the relevant overall length of all extracted tracks. The format is min:sec.</td><td></td>" "</tr>" "<tr>" "<td>$nooftracks</td><td></td><td>Prints the total number of extracted tracks.</td><td></td>" "</tr>" "<tr>" "<td>$discid</td><td>base</td><td>Prints the discid of the current cd. The attribute base is the base of the number. The default is 16 (hexadecimal).</td><td>${discid base=\"16\"}</td>" "</tr>" "<tr>" "<td>$today</td><td>format</td><td>Prints the current date. The attribute format specifies the output (*).</td><td>${today format=\"yyyy-MM-dddd\"}</td>" "</tr>" "<tr>" "<td>$now</td><td>format</td><td>Prints the current date and/or time. The attribute format specifies the output (*).</td><td>${now format=\"yyyy-MM-dddd hh:mm:ss\"}</td>" "</tr>" "<tr>" "<td>$encoder</td><td></td><td>Prints encoder name and version.</td>" "</tr>" "<tr>" "<td>$audex</td><td></td><td>Prints Audex name and version.</td>" "</tr>" "<tr>" "<td>$br</td><td></td><td>Prints a linebreak.</td><td></td>" "</tr>" "</tbody>" "</table>" "<br /><br />" "(* date/time format expressions)" "<table cellpadding=\"2\" cellspacing=\"1\" border=\"1\">" "<thead><tr valign=\"top\"><th>Expression</th><th>Output</th></tr></thead>" "<tr valign=\"top\"><td>d</td><td>The day as a number without a leading zero (1 to 31).</td></tr>" "<tr valign=\"top\"><td>dd</td><td>The day as a number with a leading zero (01 to 31).</td></tr>" "<tr valign=\"top\"><td>ddd</td><td>The abbreviated localized day name (e.g. 'Mon' to 'Sun').</td></tr>" "<tr valign=\"top\"><td>dddd</td><td>The long localized day name (e.g. 'Monday' to 'Sunday').</td></tr>" "<tr valign=\"top\"><td>M</td><td>The month as a number without a leading zero (1 to 12).</td></tr>" "<tr valign=\"top\"><td>MM</td><td>The month as a number with a leading zero (01 to 12).</td></tr>" "<tr valign=\"top\"><td>MMM</td><td>The abbreviated localized month name (e.g. 'Jan' to 'Dec').</td></tr>" "<tr valign=\"top\"><td>MMMM</td><td>The long localized month name (e.g. 'January' to 'December').</td></tr>" "<tr valign=\"top\"><td>yy</td><td>The year as two digit number (00 to 99).</td></tr>" "<tr valign=\"top\"><td>yyyy</td><td>The year as four digit number.</td></tr>" "</table>" "<br />" "<table cellpadding=\"2\" cellspacing=\"1\" border=\"1\">" "<thead><tr valign=\"top\"><th>Expression</th><th>Output</th></tr></thead>" "<tr valign=\"top\"><td>h</td><td>The hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display).</td></tr>" "<tr valign=\"top\"><td>hh</td><td>The hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display).</td></tr>" "<tr valign=\"top\"><td>H</td><td>The hour without a leading zero (0 to 23, even with AM/PM display).</td></tr>" "<tr valign=\"top\"><td>HH</td><td>The hour with a leading zero (00 to 23, even with AM/PM display).</td></tr>" "<tr valign=\"top\"><td>m</td><td>The minute without a leading zero (0 to 59).</td></tr>" "<tr valign=\"top\"><td>mm</td><td>The minute with a leading zero (00 to 59).</td></tr>" "<tr valign=\"top\"><td>s</td><td>The second without a leading zero (0 to 59).</td></tr>" "<tr valign=\"top\"><td>ss</td><td>The second with a leading zero (00 to 59).</td></tr>" "<tr valign=\"top\"><td>z</td><td>The milliseconds without leading zeroes (0 to 999).</td></tr>" "<tr valign=\"top\"><td>zz</td><td>The milliseconds with leading zeroes (000 to 999).</td></tr>" "<tr valign=\"top\"><td>AP or A</td><td>Interpret as an AM/PM time. AP must be either 'AM' or 'PM'.</td></tr>" "<tr valign=\"top\"><td>ap or a</td><td>Interpret as an AM/PM time. ap must be either 'am' or 'pm'.</td></tr>" "</table>" "</body>" "</html>" )); mainLayout->addWidget(tb); mainLayout->addWidget(buttonBox); connect(dialog, SIGNAL(clicked()), dialog, SLOT(close())); dialog->exec(); delete dialog; }