void QxtConfirmationMessagePrivate::doNotShowAgain(int result) { QSettings settings(format, scope, organizationName(), applicationName()); if (!path.isEmpty()) settings.beginGroup(path); settings.setValue(key(), result); }
void QxtConfirmationMessagePrivate::reset() { QSettings settings(format, scope, organizationName(), applicationName()); if (!path.isEmpty()) settings.beginGroup(path); settings.remove(key()); }
void QLuaApplication::about() { QWidget *w = qobject_cast<QWidget*>(sender()); QString an = applicationName(); QMessageBox::about(w, tr("About %1").arg(an), aboutMessage()); }
int QxtConfirmationMessagePrivate::showAgain() { QSettings settings(format, scope, organizationName(), applicationName()); if (!path.isEmpty()) settings.beginGroup(path); return settings.value(key(), -1).toInt(); }
void ClientApplication::start() { if (!parseCommandLine()) { QMessageBox::critical(NULL, applicationName(), trUtf8("Error in the command line arguments. Arguments:\n--host <h>\tConnect to the server on host <h>.\n--local\tRun client locally.\n--port <p>\tUse port <p> to connect to the server.")); quit(); return; } if (mode == mUnspecified) { ConnectDialog connectDialog; int code = connectDialog.exec(); if (code == QDialog::Rejected) { quit(); return; } if (connectDialog.local()) { mode = mLocal; } else { mode = mRemote; host = connectDialog.host(); port = connectDialog.port(); } } if (mode == mLocal) { theTrainer.reset(new Trainer()); showMainWindow(); } else { ProxyTrainer *trainer = new ProxyTrainer(); theTrainer.reset(trainer); connect(trainer, SIGNAL(socketConnected()), SLOT(showMainWindow())); connect(trainer, SIGNAL(socketDisconnected()), SLOT(socketDisconnected())); connect(trainer, SIGNAL(socketError(QString)), SLOT(socketError(QString))); trainer->socketConnectToHost(host, port); } }
void Version::logBuildDetails() { QString version = Version::version(); QString buildBranch = developmentBranch(); QString buildRevision = developmentRevision(); QString buildFlags = Version::buildFlags(); QStringList buildInfo; if (!buildBranch.isEmpty() && !buildRevision.isEmpty()) { buildInfo.append( QString("git %1 r%2").arg(buildBranch, buildRevision)); } else if (!buildRevision.isEmpty()) { buildInfo.append( QString("git r%2").arg(buildRevision)); } #ifndef DISABLE_BUILDTIME // buildtime=1, on by default buildInfo.append("built on: " __DATE__ " @ " __TIME__); #endif if (!buildFlags.isEmpty()) { buildInfo.append(QString("flags: %1").arg(buildFlags.trimmed())); } QString buildInfoFormatted = QString("(%1)").arg(buildInfo.join("; ")); // This is the first line in mixxx.log qDebug() << applicationName() << version << buildInfoFormatted << "is starting..."; QStringList depVersions = dependencyVersions(); qDebug() << "Library versions:"; foreach (const QString& depVersion, depVersions) { qDebug() << qPrintable(depVersion); }
void TheApp::showUsage(tostream& out) const { out << std::endl; out << TXT("USAGE: ") << applicationName() << (" [options] ...") << std::endl; out << std::endl; out << m_parser.formatSwitches(Core::CmdLineParser::UNIX); }
void App::setWindowTitle(QWidget *widget, const QString &title) { // _Trace("Set window title of %% to '%%'.", widget->metaObject()->className(), title); const QString text = title % (title.isEmpty() ? "" : " - ") % applicationName(); widget->setWindowTitle(text); #ifdef Q_OS_LINUX d->helper.setWmName(widget, text); #endif }
QMessageBox::StandardButton Application::question( const QString &message, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton ) { return QMessageBox::question(0, applicationName(), message, buttons, defaultButton); }
Blackbox::Blackbox(char **m_argv, const char *dpy_name, const std::string& rc, bool multi_head) : bt::Application(m_argv[0], dpy_name, multi_head), grab_count(0u), _resource(rc) { if (! XSupportsLocale()) fprintf(stderr, _("X server does not support locale\n")); if (XSetLocaleModifiers("") == NULL) fprintf(stderr, _("cannot set locale modifiers\n")); argv = m_argv; active_screen = 0; focused_window = (BlackboxWindow *) 0; _ewmh = (bt::EWMH*) 0; init_icccm(); if (! multi_head || display().screenCount() == 1) screen_list_count = 1; else screen_list_count = display().screenCount(); _resource.load(*this); screen_list = new BScreen*[screen_list_count]; unsigned int managed = 0; for (unsigned int i = 0; i < screen_list_count; ++i) { BScreen *screen = new BScreen(this, i); if (! screen->isScreenManaged()) { delete screen; continue; } screen_list[i] = screen; ++managed; } if (managed == 0) { fprintf(stderr, _("%s: no manageable screens found, exiting...\n"), applicationName().c_str()); ::exit(3); } screen_list_count = managed; // start with the first managed screen as the active screen setActiveScreen(screen_list[0]); XSynchronize(XDisplay(), false); XSync(XDisplay(), false); timer = new bt::Timer(this, this); timer->setTimeout(0l); }
const QString WiresharkApplication::windowTitleString(QStringList title_parts) { QMutableStringListIterator tii(title_parts); while (tii.hasNext()) { QString ti = tii.next(); if (ti.isEmpty()) tii.remove(); } title_parts.prepend(applicationName()); return title_parts.join(window_title_separator_); }
void Application::aboutApplication() { QMessageBox::about( #ifdef Q_WS_MAC 0, #else activeWindow(), #endif // Q_WS_MAC applicationName(), QString( "<h3>%1</h3>" "<p>%2</p>" "<p><a href='%3'>%3</a></p>" "<p><small>Copyright (C) 2008-2012 J-P Nurmi <" "<a href='mailto:[email protected]'>[email protected]</a>></small></p>") .arg(tr("About %1").arg(applicationName())) .arg(applicationSlogan()) .arg(organizationDomain()) ); }
/** * Displays application and version information. */ void Application::about() { QString msg; QTextStream str(&msg); str << "Source browsing, analysis and editing\n"; str << "Version " << applicationVersion() << "\n"; str << "Copyright (c) 2007-2009 by Elad Lahav\n"; str << "Distributed under the terms of the GNU Public License v2"; QMessageBox::about(mainWnd_, applicationName(), msg); }
int Application::exec() { Info(tr("%1 started.").arg(applicationName())); LogStartSection(); _mainController = new MainController(); QMetaObject::invokeMethod(mainController(), "start", Qt::QueuedConnection); int applicationResult = QApplication::exec(); LogFinishSection(); Info(tr("Appliction finished.")); return applicationResult; }
bool L2tpIPsecVpnApplication::notify(QObject* pReceiver, QEvent* pEvent) { bool fRet(false); try { fRet = QApplication::notify(pReceiver, pEvent); } catch(const ErrorEx& e) { qCritical() << "Exception thrown:" << e.getString(); QMessageBox::critical(NULL, applicationName(), e.getString()); } return(fRet); }
void FbxAPI::requestAuthorize() { QJsonObject json; json.insert("app_id", applicationId()); json.insert("app_name",applicationName()); json.insert("app_version",applicationVersion()); json.insert("device_name", QHostInfo::localHostName()); QNetworkRequest request = myCreateRequest("login/authorize"); QNetworkReply * reply = post(request,QJsonDocument(json).toJson()); connect(reply,SIGNAL(finished()),this,SLOT(requestAuthorizeFinished())); connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(errorReceived(QNetworkReply::NetworkError))); }
void QkUiApplication::runApp() { log()->source("MAIN"); log()->addStdLoggers(); log()->start(); log()->installQtHandler(); log()->info(applicationName() + " loaded."); log()->appendSystemInfo().direct(); QTranslator* apptr = new QTranslator(); if (apptr->load("qt_ru.qm", "/usr/share/qt/translations")) { installTranslator(apptr); } else { log()->warn(tr("Не удалось загрузить переводы Qt")); } }
ccApplication::ccApplication(int &argc, char **argv) : QApplication( argc, argv ) { setOrganizationName( "CCCorp" ); setApplicationName( "CloudCompare" ); #ifdef Q_OS_MAC // Mac OS X apps don't show icons in menus setAttribute( Qt::AA_DontShowIconsInMenus ); #endif // Force 'english' locale so as to get a consistent behavior everywhere QLocale::setDefault( QLocale( QLocale::English ) ); #ifdef Q_OS_UNIX // We reset the numeric locale for POSIX functions // See https://doc.qt.io/qt-5/qcoreapplication.html#locale-settings setlocale( LC_NUMERIC, "C" ); #endif FileIO::setWriterInfo( applicationName(), s_version ); connect( this, &ccApplication::aboutToQuit, [=](){ ccMaterial::ReleaseTextures(); } ); }
int L2tpIPsecVpnApplication::startConnectionEditorDialog(bool fDetached) const { int iRet(0); const char* const pcDesktopSession(::getenv(DESKTOP_SESSION)); const QString strSu(L2tpIPsecVpnApplication::getGrahicalSUCmdLine()); if (!strSu.isEmpty()) { const QString strProgram(strSu + arguments()[0] + " " + CONNECTIONEDITOR_CMD_SWITCH + " " + (pcDesktopSession ? DESKTOP_SESSION_CMD_SWITCH + " " + pcDesktopSession : "")); if (fDetached) iRet = !QProcess::startDetached(strProgram); else m_pProcess->start(strProgram); } else { QMessageBox::critical(NULL, applicationName(), tr("I couldn't find any graphical SU command (gksudo, beesu kdesudo or kdesu).")); iRet = -1; } return(iRet); }
bool Application::init() try { // initialize resources #if !defined(DESKTOP) Q_INIT_RESOURCE(keyboard); Q_INIT_RESOURCE(rotation); Q_INIT_RESOURCE(eink); #if defined(EINK) setCursorFlashTime(0); #endif #endif QString logFile( Platform::get()->getUserSettingsPath() + QDir::separator() + applicationName() + ".log.txt" ); g_pLog = new Log( QFile::encodeName(logFile).constData(), 1, 1 ); g_pConfig = new Config(applicationName()); int logLevel = g_pConfig->readInt("log_level", -1); if ( -1 == logLevel ) { logLevel = qgetenv("VLASOVSOFT_LOG").toInt(); } if ( logLevel < 0 ) logLevel = 0; if ( logLevel > 2 ) logLevel = 2; g_pLog->setLevel( logLevel ); g_pLog->write(1, Log::MT_I, "Program started, version: %s.%s", VERSION, REVISION); // set default application font QFont fnt = font(); fnt.setPointSize(Platform::get()->getDefaultFontSize()); setFont(fnt); #if defined(EINK) // set palette QPalette pal = palette(); pal.setColor(QPalette::Window, Qt::white); pal.setColor(QPalette::Highlight, Qt::black); setPalette(pal); #endif #if defined(ANDROID) || defined(SIMPLE) || defined(IOS) QPalette pal = palette(); pal.setColor(QPalette::Highlight, Qt::darkBlue); pal.setColor(QPalette::HighlightedText, Qt::white); setPalette(pal); #endif #if !defined(DESKTOP) StyleEbook* pStyle = new StyleEbook(style()); int bSize = g_pConfig->readInt( "button_size", 40 ); // 40 = 1 cm QSize size( getSizePx( QSize(bSize, bSize), 5 ) ); pStyle->setButtonIconSize(qMax( size.width(), size.height() )); setStyle(pStyle); #endif #if defined(Q_WS_QWS) QWSServer::setBackground(QBrush(Qt::black)); setNavigationMode( Qt::NavigationModeKeypadDirectional ); #endif #if defined(ANDROID) installEventFilter(&kf); #endif loadTranslations(); customInit(); return true; } catch(const Exception& e) { if ( g_pLog != NULL ) g_pLog->write(1, Log::MT_F, "Fatal error: %s", e.what()); ::messageBox(0, QMessageBox::Critical, qApp->translate("main", "Error:"), QString::fromLocal8Bit(e.what()) ); return false; } catch(...) { if ( g_pLog != NULL ) g_pLog->write(1, Log::MT_F, "Fatal error!"); ::messageBox(0, QMessageBox::Critical, qApp->translate("main", "Error:"), "Fatal error!" ); return false; }
void Application::information(QString message) { QMessageBox::information(0, applicationName(), message); }
void Application::critical(QString message) { QMessageBox::critical(0, applicationName(), message); }
bool parseCmdLineArgs(int argc, char** argv, std::string& name, std::string& connectionType, std::string& address, WindowGeometry& geometry, bool& fullscreen, bool& always_on_top, bool& stereo) { for(int i=1 ; i<argc ; ++i) { if(argv[i][0] == '-') { std::string applicationName(argv[0]); std::string geometryStr; int nextArgIdx; switch(argv[i][1]) { case 's': stereo = true; break; case 'm': connectionType="Multicast"; break; case 'w': fullscreen=false; break; case 't': always_on_top = true; break; case 'a': nextArgIdx = ++i; if (nextArgIdx >= argc) { std::cerr << "ERROR: No address specified" << std::endl; usage(applicationName); return false; } address = argv[nextArgIdx]; if (!validateAddress(address)) { std::cerr << "ERROR: No valid IP4 address (in the form xxx.xxx.xxx.xxx) specified" << std::endl; usage(applicationName); return false; } break; case 'g': nextArgIdx = ++i; if (nextArgIdx >= argc) { std::cerr << "ERROR: No Window Geometry specified" << std::endl; usage(applicationName); return false; } geometryStr = argv[nextArgIdx]; if (!parseWindowGeometry(geometryStr, geometry)) { std::cerr << "ERROR: Malformed geometry: " << geometryStr << std::endl; usage(applicationName); return false; } break; case 'd': nextArgIdx = ++i; //display will be caught by glutInit, skip it, + its value /*if (strcmp(&argv[i][1], "display")==0) { }*/ break; // incorrect value falls through to bomb out... default: usage(applicationName); return false; } } else { name = argv[i]; } } return true; }
void Application::parseArguments(QStringList args) { QFileInfo program(args.at(0)); QString programName("renderer"); if (program.exists()) programName = program.baseName(); if (args.contains("-h") || args.contains("-help") || args.contains("--help")) { std::cout << "Usage: " << programName.toLatin1().data() << " [-version]" << " [-gui]" << " [-bookjs path]" << " [-custom-css path]" << " [-output path]" << " URL" << std::endl; appQuit(0); } if (args.contains("-version")) { std::cout << applicationName().toLatin1().data() << " " << applicationVersion().toLatin1().data() #if defined(Q_PROCESSOR_X86_32) << " x86" #elif defined(Q_PROCESSOR_X86_64) << " amd64" #endif << std::endl; appQuit(0); } m_gui = args.contains("-gui"); int bookjsPathIndex = args.indexOf("-bookjs"); if (bookjsPathIndex != -1) { QString path = takeOptionValue(&args, bookjsPathIndex); QDir dir(path); if (! dir.exists()) { appQuit(1, QString("path does not point to a directory: %1").arg(path)); } m_rendererOptions.bookjsPath = dir.absolutePath(); } int cssPathIndex = args.indexOf("-custom-css"); if (cssPathIndex != -1) { QString path = takeOptionValue(&args, cssPathIndex); if (! QFileInfo(path).isReadable()) { appQuit(1, QString("file does not exist or is not readable: %1").arg(path)); } QFile file(path); if (! file.open(QFile::ReadOnly)) { appQuit(1, QString("cout not open file: %1").arg(path)); } m_rendererOptions.customCSS = QTextStream(&file).readAll(); } int outputPathIndex = args.indexOf("-output"); if (outputPathIndex != -1) m_rendererOptions.outputFilePath = takeOptionValue(&args, outputPathIndex); int lastArg = args.lastIndexOf(QRegExp("^-.*")); m_urls = (lastArg != -1) ? args.mid(++lastArg) : args.mid(1); }
QSharedPointer<CaptureDevice> TimeLapseCapture::parseArguments() { QCommandLineParser parser; ErrorMessageHelper die(err.device(), &parser); parser.setApplicationDescription("Tool for capture sequence of images from digital camera (V4L or GPhoto2 API)."); parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption outputOption(QStringList() << "o" << "output", QCoreApplication::translate("main", "Output directory."), QCoreApplication::translate("main", "directory")); parser.addOption(outputOption); QCommandLineOption verboseOption(QStringList() << "V" << "verbose", QCoreApplication::translate("main", "Verbose output.")); parser.addOption(verboseOption); QCommandLineOption deviceOption(QStringList() << "d" << "device", QCoreApplication::translate("main", "Capture device."), QCoreApplication::translate("main", "device")); parser.addOption(deviceOption); QCommandLineOption listOption(QStringList() << "l" << "list", QCoreApplication::translate("main", "List available capture devices and exits.")); parser.addOption(listOption); QCommandLineOption intervalOption(QStringList() << "i" << "interval", QCoreApplication::translate("main", "Capture interval (in milliseconds). Default is 10000."), QCoreApplication::translate("main", "interval")); parser.addOption(intervalOption); QCommandLineOption cntOption(QStringList() << "c" << "count", QCoreApplication::translate("main", "How many images should be captured. Default value is infinite."), QCoreApplication::translate("main", "count")); parser.addOption(cntOption); QCommandLineOption rowOption(QStringList() << "r" << "raw", QCoreApplication::translate("main", "Store all captured images in raw.")); parser.addOption(rowOption); QCommandLineOption getShutterSpeedOption(QStringList() << "s" << "shutterspeed-options", QCoreApplication::translate("main", "Prints available shutterspeed setting choices and exits.")); parser.addOption(getShutterSpeedOption); QCommandLineOption adaptiveShutterSpeedOption(QStringList() << "a" << "adaptive-shutterspeed", QCoreApplication::translate("main", "Camera shutterspeed will be adaptively changed after exposure metering.\n" "This option setup how many images should be used for exposure metering. \n" "Default value is 0 - it means that shutterspeed will not be changed by capture tool." ), QCoreApplication::translate("main", "count")); parser.addOption(adaptiveShutterSpeedOption); QCommandLineOption shutterSpeedStepOption(QStringList() << "shutterspeed-step", QCoreApplication::translate("main", "How large should be step when changing shutterspeed. \n" "Default value is 1." ), QCoreApplication::translate("main", "step")); parser.addOption(shutterSpeedStepOption); QCommandLineOption minShutterSpeedOption(QStringList() << "min-shutterspeed", QCoreApplication::translate("main", "Minimum shutterspeed (fastest shutter) used by adaptive shutterspeed"), QCoreApplication::translate("main", "shutterspeed")); parser.addOption(minShutterSpeedOption); QCommandLineOption maxShutterSpeedOption(QStringList() << "max-shutterspeed", QCoreApplication::translate("main", "Maximum shutterspeed (slowest shutter) used by adaptive shutterspeed.\n" "If camera supports BULB shutterspeed, it can be defined as \"BULB:XX\" here (it means bulb with XX s exposure)." ), QCoreApplication::translate("main", "shutterspeed")); parser.addOption(maxShutterSpeedOption); // Process the actual command line arguments given by the user parser.process(*this); // verbose? if (!parser.isSet(verboseOption)) { blackHole = new BlackHoleDevice(); verboseOutput.setDevice(blackHole); } else { // verbose verboseOutput << "Turning on verbose output..." << endl; verboseOutput << applicationName() << " " << applicationVersion() << endl; } // raw? storeRawImages = parser.isSet(rowOption); // interval if (parser.isSet(intervalOption)) { bool ok = false; long i = parser.value(intervalOption).toLong(&ok); if (!ok) die << "Cant parse interval."; if (i <= 0) die << "Interval have to be possitive"; interval = i; } // count if (parser.isSet(cntOption)) { bool ok = false; int i = parser.value(cntOption).toInt(&ok); if (!ok) die << "Cant parse count."; cnt = i; } // list devices? QList<QSharedPointer < CaptureDevice>> devices = listDevices(); QSharedPointer<CaptureDevice> dev; if (parser.isSet(listOption)) { if (devices.isEmpty()) { die << QCoreApplication::translate("main", "No compatible capture device found"); } else { out << "Found devices: " << endl; for (QSharedPointer<CaptureDevice> d : devices) { out << " " << d->toString() << endl; } } std::exit(0); } // capture device bool assigned = false; if (!parser.isSet(deviceOption)) { verboseOutput << "Found devices: " << endl; for (QSharedPointer<CaptureDevice> d : devices) { if (!assigned) { dev = d; assigned = true; } verboseOutput << " " << d->toString() << endl; } if (!assigned) die << "No supported device."; } else { QString devVal = parser.value(deviceOption); for (QSharedPointer<CaptureDevice> d : devices) { if (d->toString().contains(devVal, Qt::CaseInsensitive)) { assigned = true; dev = d; break; } } if (!assigned) { die << QString("No device matching \"%1\" found.").arg(devVal); } } out << "Using device " << dev->toString() << endl; // getShutterSpeedOption ? QList<ShutterSpeedChoice> choices = dev->getShutterSpeedChoices(); if (parser.isSet(getShutterSpeedOption)) { if (choices.isEmpty()) { err << "Device " << dev->toShortString() << " don't support shutterspeed setting" << endl; } else { out << "Device " << dev->toShortString() << " shutterspeed choices:" << endl; for (ShutterSpeedChoice ch : choices) { out << " " << ch.toString() << endl; } out << "Current shutter speed: " << dev->currentShutterSpeed().toString() << endl; } std::exit(0); } // automatic chutter speed // this functionality is experimental! if (parser.isSet(adaptiveShutterSpeedOption)) { bool ok = false; int changeThreshold = parser.value(adaptiveShutterSpeedOption).toInt(&ok); if (!ok) die << "Cant parse adaptive shutterspeed option."; if (changeThreshold > 0) { if (choices.isEmpty()) { die << "Camera don't support shutterspeed setting."; } else { ShutterSpeedChoice currentShutterSpeed; ShutterSpeedChoice minShutterSpeed; ShutterSpeedChoice maxShutterSpeed; currentShutterSpeed = dev->currentShutterSpeed(); minShutterSpeed = choices.first(); for (ShutterSpeedChoice ch : choices) { if ((!ch.isBulb()) && ch.toMicrosecond() > maxShutterSpeed.toMicrosecond()) maxShutterSpeed = ch; } int shutterSpeedStep = 1; if (parser.isSet(shutterSpeedStepOption)) { bool ok = false; shutterSpeedStep = parser.value(shutterSpeedStepOption).toInt(&ok); if (!ok) die << "Cant parse shutterspeed step."; if (shutterSpeedStep < 1) die << "Shutterspeed step can be less than one."; } if (parser.isSet(minShutterSpeedOption)) { QString optStr = parser.value(minShutterSpeedOption); minShutterSpeed = getShutterSpeed(optStr, choices, &die); } if (parser.isSet(maxShutterSpeedOption)) { QString optStr = parser.value(maxShutterSpeedOption); maxShutterSpeed = getShutterSpeed(optStr, choices, &die); } out << "Using automatic shutter speed:" << endl; out << " current shutter speed: " << currentShutterSpeed.toString() << endl; out << " min shutter speed: " << minShutterSpeed.toString() << endl; out << " max shutter speed: " << maxShutterSpeed.toString() << endl; out << " change threshold: " << changeThreshold << endl; out << " change step: " << shutterSpeedStep << endl; if (minShutterSpeed.toMicrosecond() <= 0 || maxShutterSpeed.toMicrosecond() <= 0 || maxShutterSpeed.toMicrosecond() < minShutterSpeed.toMicrosecond()) die << "Invalid shutter speed configurarion"; if (maxShutterSpeed.toMs() > interval) { err << QString("Warning: Maximum shutter speed (%1 ms) is greater than capture interval (%2 ms)!") .arg(maxShutterSpeed.toMs()) .arg(interval) << endl; } shutterSpdAlg = new MatrixMeteringAlg(choices, currentShutterSpeed, minShutterSpeed, maxShutterSpeed, &err, &verboseOutput, changeThreshold, shutterSpeedStep); } } } // output if (!parser.isSet(outputOption)) die << "Output directory is not set"; output = QDir(parser.value(outputOption)); if (output.exists()) err << "Output directory exists already." << endl; if (!output.mkpath(".")) die << QString("Can't create output directory %1 !").arg(output.path()); return dev; }
void ClientApplication::socketDisconnected() { QMessageBox::critical(NULL, applicationName(), trUtf8("QGameTrainerClient was disconnected from the server.")); quit(); }
Application::Application(int &argc, char *argv[]) : QApplication(argc, argv) { QTextCodec *codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForTr(codec); QTextCodec::setCodecForCStrings(codec); QTranslator *qtTr = new QTranslator(this); QTranslator *appTr = new QTranslator(this); QStringList trDirs; trDirs += QLibraryInfo::location(QLibraryInfo::TranslationsPath); trDirs += ":/translations/"; QString locale = QLocale::system().name().toLower(); foreach (QString dir, trDirs) if (qtTr->load("qt_" + locale, dir)) break; installTranslator(qtTr); foreach (QString dir, trDirs) { #ifdef Q_WS_MAC if (appTr->load("qpeercastyp_osx_" + locale, dir)) #else if (appTr->load("qpeercastyp_" + locale, dir)) #endif break; } foreach (QString dir, trDirs) { if (appTr->load(locale, dir)) { break; } } installTranslator(appTr); QString appName = "QPeerCastYP"; setApplicationName(appName); setOrganizationName(appName); #ifndef Q_WS_MAC setWindowIcon(applicationIcon()); #endif Network::setUserAgent(QString("Mozilla/4.0 (%1/%2; %3; %4)") .arg(appName).arg(VERSION).arg(Utils::wsString()).arg(Utils::osString())); Settings *defaultSettings = new Settings(":/default.conf", QSettings::IniFormat); #ifdef Q_WS_WIN m_settings = new Settings(QSettings::IniFormat, QSettings::UserScope, organizationName(), applicationName(), defaultSettings); #else m_settings = new Settings(QSettings::NativeFormat, QSettings::UserScope, organizationName(), applicationName(), defaultSettings); #endif // Q_WS_WIN SettingsConverter::convert(m_settings); m_settings->setValue("General/Version", VERSION); bool firstRun = m_settings->value("General/FirstRun").toBool(); if (firstRun) { m_settings->setValue("General/FirstRun", false); QString ws = Utils::wsString(); if (ws != "Unknown") { int size = defaultSettings->beginReadArray(QString("Player%1/Items").arg(ws)); m_settings->beginWriteArray("Player/Items"); for (int i = 0; i < size; ++i) { defaultSettings->setArrayIndex(i); m_settings->setArrayIndex(i); m_settings->setValue("Types", defaultSettings->value("Types")); m_settings->setValue("Program", defaultSettings->value("Program")); m_settings->setValue("Args", defaultSettings->value("Args")); } defaultSettings->endArray(); m_settings->endArray(); } } m_yellowPageManager = new YellowPageManager(m_settings); m_mainWindow = new MainWindow(); m_mainWindow->setup(); m_mainWindow->show(); m_mainWindow->setUnifiedTitleAndToolBarOnMac(true); m_systemTrayIcon = new SystemTrayIcon(this); if (m_settings->value("SystemTrayIcon/Enabled").toBool()) m_systemTrayIcon->show(); m_peercast = new QProcess(this); if (m_settings->value("AtStartup/RunPeerCast").toBool()) { QString program = m_settings->value("Program/PeerCast").toString(); QStringList args = Utils::shellwords(m_settings->value("Program/PeerCastArgs").toString()); if (!program.isEmpty()) { m_peercast->setWorkingDirectory(QFileInfo(program).dir().absolutePath()); m_peercast->start(program, args); if (!m_peercast->waitForStarted()) QMessageBox::warning(m_mainWindow, tr("エラー"), tr("PeerCast の起動に失敗しました。")); } else { qWarning() << tr("PeerCast プログラムが設定されていません。"); } } if (m_settings->value("AtStartup/UpdateYellowPage").toBool()) QTimer::singleShot(1 * 1000, m_mainWindow->actions()->updateYellowPageAction(), SLOT(trigger())); }
void ClientApplication::socketError(QString errorString) { QMessageBox::critical(NULL, applicationName(), trUtf8("A network error occurred. %1.").arg(errorString)); quit(); }
QString QLuaApplication::aboutMessage() const { QString an = applicationName(); return d->aboutMessage.replace("${APPNAME}", an); }
QString Application::applicationSlogan() { return tr("%1 is a simple and light-weight cross-platform IRC client.").arg(applicationName()); }