bool MainWindow::showSaveOnCloseDialog() { if (has_opened_file && (has_unsaved_changes || has_autosave_conflict)) { // Show the window in case it is minimized setWindowState( (windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); raise(); activateWindow(); QMessageBox::StandardButton ret; if (!has_unsaved_changes && actual_path != autosavePath(currentPath())) { ret = QMessageBox::warning(this, appName(), tr("Do you want to remove the autosaved version?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); } else { ret = QMessageBox::warning(this, appName(), tr("The file has been modified.\n" "Do you want to save your changes?"), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); } switch (ret) { case QMessageBox::Cancel: return false; case QMessageBox::Discard: if (has_autosave_conflict) setHasAutosaveConflict(false); else removeAutosaveFile(); break; case QMessageBox::Save: if (!save()) return false; // fall through case QMessageBox::Yes: setHasAutosaveConflict(false); removeAutosaveFile(); break; case QMessageBox::No: setHasAutosaveConflict(false); break; default: Q_ASSERT(false && "Unsupported return value from message box"); break; } } return true; }
//______________________________________________________________ void ArgbHelper::registerApplication( QApplication* app ) { // get application full path if( app->argc() < 1 ) return; QString appName( app->argv()[0] ); int position( appName.lastIndexOf( '/' ) ); if( position >= 0 ) appName.remove( 0, position+1 ); if( appName == "plasma" || appName.startsWith( "plasma-" ) ) { /* HACK: need to detect if application is of type Plasma because applying translucency to some of its widgets creates painting issues which could not be identified with a 'generic' criteria. */ _applicationType = AppPlasma; } else if( _blackList.contains( appName ) ) { // black-list application _applicationType = AppBlackListed; } }
status_t OpenAction(const BMessage &action, entry_ref &ref) { entry_ref app; BString appName(""); if (be_roster->FindApp(&ref,&app) == B_OK) appName = app.name; status_t status = be_roster->Launch(&ref); if (status == B_OK) printf("\tOpened %s in program %s\n",ref.name,appName.String()); else { // R5 (and probably others) don't seem to want to open folders in Tracker -- // FindApp() returns B_OK, but sets the entry_ref of the app to open it to // the folder's ref, which is dumb. This works around this apparent stupidity. BString typestr; if (BNode(&ref).ReadAttrString("BEOS:TYPE",&typestr) == B_OK && typestr.Compare("application/x-vnd.Be-directory") == 0) { BMessage *msg = new BMessage(B_REFS_RECEIVED); msg->AddRef("refs",&ref); be_roster->Launch("application/x-vnd.Be-TRAK",msg); printf("\tOpened %s in program Tracker\n",ref.name); return B_OK; } if (appName.CountChars() > 0) printf("\tCouldn't open %s in program %s\n",ref.name,appName.String()); else printf("\tCouldn't open %s -- the system couldn't find a program to do it.\n",ref.name); } return status; }
int main(int argc, char **argv) { QString appName(argv[0]); int retval = 1; if (appName.endsWith("fali_mw1")) { MultiWindowApplication app(argc, argv, "com.nokia.fali_mw1"); MApplication::setPrestartMode(M::LazyShutdownMultiWindow); app.createWindows(); retval = app.exec(); } else if (appName.endsWith("fali_mw2")) { MultiWindowApplication app(argc, argv, "com.nokia.fali_mw2"); MApplication::setPrestartMode(M::TerminateOnCloseMultiWindow); app.createWindows(); retval = app.exec(); } else { qWarning("Unrecognized executable name!"); } return retval; }
void MainWindow::switchActualPath(const QString& path) { if (path == actual_path) { return; } int ret = QMessageBox::Ok; if (has_unsaved_changes) { ret = QMessageBox::warning(this, appName(), tr("The file has been modified.\n" "Do you want to discard your changes?"), QMessageBox::Discard | QMessageBox::Cancel); } if (ret != QMessageBox::Cancel) { const QString& current_path = currentPath(); MainWindowController* const new_controller = MainWindowController::controllerForFile(current_path); if (new_controller && new_controller->load(path, this)) { setController(new_controller, current_path); actual_path = path; setHasUnsavedChanges(false); } } emit actualPathChanged(actual_path); activateWindow(); }
void hlpScreen(void) { if(dosish) message(stdout, join? E_JOIN_E: E_SUBST_E); else message(stdout, E_hlpScreen, appName(), join? "/j": "/u"); exit(msgErrorNumber(E_hlpScreen)); }
void MainWindow::createHelpMenu() { // Help menu QAction* manualAct = new QAction(QIcon(QString::fromLatin1(":/images/help.png")), tr("Open &Manual"), this); manualAct->setStatusTip(tr("Show the help file for this application")); manualAct->setShortcut(QKeySequence::HelpContents); connect(manualAct, &QAction::triggered, this, &MainWindow::showHelp); QAction* aboutAct = new QAction(tr("&About %1").arg(appName()), this); aboutAct->setStatusTip(tr("Show information about this application")); aboutAct->setMenuRole(QAction::AboutRole); connect(aboutAct, &QAction::triggered, this, &MainWindow::showAbout); QAction* aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct->setStatusTip(tr("Show information about Qt")); aboutQtAct->setMenuRole(QAction::AboutQtRole); connect(aboutQtAct, &QAction::triggered, qApp, QApplication::aboutQt); if (show_menu) { QMenu* helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(manualAct); helpMenu->addAction(QWhatsThis::createAction(this)); helpMenu->addSeparator(); helpMenu->addAction(aboutAct); helpMenu->addAction(aboutQtAct); } }
void SyslogParser::parseNew(const std::string& msg, RemoteSyslogChannel::Severity severity, RemoteSyslogChannel::Facility fac, std::size_t& pos) { Poco::Message::Priority prio = convert(severity); // rest of the unparsed header is: // VERSION SP TIMESTAMP SP HOSTNAME SP APP-NAME SP PROCID SP MSGID std::string versionStr(parseUntilSpace(msg, pos)); std::string timeStr(parseUntilSpace(msg, pos)); // can be the nilvalue! std::string hostName(parseUntilSpace(msg, pos)); std::string appName(parseUntilSpace(msg, pos)); std::string procId(parseUntilSpace(msg, pos)); std::string msgId(parseUntilSpace(msg, pos)); std::string message(msg.substr(pos)); pos = msg.size(); Poco::DateTime date; int tzd = 0; bool hasDate = Poco::DateTimeParser::tryParse(RemoteSyslogChannel::SYSLOG_TIMEFORMAT, timeStr, date, tzd); Poco::Message logEntry(msgId, message, prio); logEntry["host"] = hostName; logEntry["app"] = appName; if (hasDate) logEntry.setTime(date.timestamp()); int lval(0); Poco::NumberParser::tryParse(procId, lval); logEntry.setPid(lval); _pListener->log(logEntry); }
void UpdateApplication::startDownload() // ---------------------------------------------------------------------------- // Start downloading the URL of the Tao file // ---------------------------------------------------------------------------- { IFTRACE(update) debug() << "Downloading: '" << +url.toString() << "'\n"; XL_ASSERT(!reply); XL_ASSERT(!url.isEmpty()); progress->setLabelText(tr("Downloading %1 %2...").arg(appName()) .arg(remoteVer())); progress->show(); state = Downloading; downloadTime.start(); request.setUrl(url); reply = manager->get(request); connect(reply, SIGNAL(metaDataChanged()), this, SLOT(processReply())); connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished())); connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); }
QString ownCloudTheme::about() const { QString devString; #ifdef GIT_SHA1 const QString githubPrefix(QLatin1String( " https://github.com/owncloud/mirall/commit/")); const QString gitSha1(QLatin1String(GIT_SHA1)); devString = QCoreApplication::translate("ownCloudTheme::about()", "<p><small>Built from Git revision <a href=\"%1\">%2</a>" " on %3, %4<br>using OCsync %5 and Qt %6.</small><p>") .arg(githubPrefix+gitSha1).arg(gitSha1.left(6)) .arg(__DATE__).arg(__TIME__) .arg(MIRALL_STRINGIFY(LIBCSYNC_VERSION)) .arg(QT_VERSION_STR); #endif return QCoreApplication::translate("ownCloudTheme::about()", "<p><b>%1 Client Version %2</b></p>" "<p><b>Authors</b>" "<br><a href=\"mailto:[email protected]\">" "Klaas Freitag</a>, ownCloud, Inc." "<br><a href=\"mailto:[email protected]\">" "Daniel Molkentin</a>, ownCloud, Inc." "<br><br>Based on Mirall by Duncan Mac-Vicar P.</p>" "<p>For more information visit <a href=\"%3\">%4</a>.</p>" "%7" ) .arg(appName()) .arg(MIRALL_STRINGIFY(MIRALL_VERSION)) .arg("http://" MIRALL_STRINGIFY(APPLICATION_DOMAIN)) .arg(MIRALL_STRINGIFY(APPLICATION_DOMAIN)) .arg(devString); }
TEST(pipelineBaseTest, common_opts) { const std::string cmd = appName(); std::string output; int stat = pdal::Utils::run_shell_command(cmd + " -h", output); EXPECT_EQ(stat, 0); }
const char * KAboutData::productName() const { if (d->productName) return d->productName; else return appName(); }
std::string GlobalSettings::appTitle() { std::string title = appName() + appVersion(std::string(" v")) + " " + m_platform; if(m_isBetaVersion) title += " - BETA VERSION"; if(m_isAlphaVersion) title += " - ALPHA VERSION"; return title; }
void Q2XMLFile::reset() { // find first set of metrics // = first app -> functions -> first functionp if(Control::debugging) cout << "Resetting Q2XML iterator..." << endl; string appName(Control::APPNAME); ticpp::Element *profTag, *appTag, *qduTag , *chTag; try { profTag = m_file.FirstChildElement(m_namespace + "profiles"); } catch (ticpp::Exception& ex) { profTag=new ticpp::Element(m_namespace + "profiles"); profTag->SetAttribute("xmlns:q2","http://www.example.org/q2profiling"); profTag->SetAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"); profTag->SetAttribute("xsi:schemaLocation","http://www.example.org/q2profiling q2profiling.xsd"); m_file.LinkEndChild(profTag); } // get application with name <appName> ticpp::Iterator< ticpp::Element > appItr(m_namespace + "application"); for(appItr = appItr.begin(profTag); appItr != appItr.end(); appItr++) { if(appItr->GetAttribute("name").compare(appName) == 0) { break; } } if(appItr == appItr.end()) { // add new tag appTag = new ticpp::Element(m_namespace + "application"); appTag->SetAttribute("name",appName); profTag->LinkEndChild(appTag); } else appTag = appItr.Get(); m_appfinger = appTag; //get QDU tag try { qduTag = appTag->FirstChildElement(m_namespace + "QDUGraph"); } catch (ticpp::Exception& ex) { qduTag = new ticpp::Element(m_namespace + "QDUGraph"); appTag->LinkEndChild(qduTag); } m_qdufinger = qduTag; }
QString ScPaths::defaultImageEditorApp() { #ifdef Q_OS_MAC QString appName("/Applications/GIMP.app"); QFile app(appName); if (app.exists()) return appName; #endif return "gimp"; }
//----------------------------------------------------------------------------- void C[!output SAFE_PROJECT_NAME]App::initRegistryInfo () { //----- Add the resource only Dll info AecRegistryInfo *reginfo =appRegistryInfo () ; if ( reginfo != NULL ) { reginfo->getRegistryString (_DNT("Language"), _DNT("CurrentLanguage"), _DNT("English"), TRUE) ; CString locale ("Language\\English") ; CString dllName =appName () + _DNT("Enu.dll") ; reginfo->writeRegistryString (locale, (LPCTSTR)(C[!output SAFE_PROJECT_NAME]App::getApp ()->appName ()), dllName) ; } }
TEST(pipelineBaseTest, no_input) { const std::string cmd = appName(); std::string output; int stat = pdal::Utils::run_shell_command(cmd, output); EXPECT_NE(0, stat); const std::string expected = "usage: pdal pipeline [options] [input]"; EXPECT_EQ(expected, output.substr(0, expected.length())); }
TEST(pipelineBaseTest, no_input) { const std::string cmd = appName(); std::string output; int stat = pdal::Utils::run_shell_command(cmd, output); EXPECT_EQ(stat, 1); const std::string expected = "Usage error: input file name required"; EXPECT_EQ(output.substr(0, expected.length()), expected); }
GNC::GCS::AnnotationSettings::AnnotationSettings() { //default annotation settings... { /* Paciente: ${0010|0020:?} // {PatientId} Id Paciente: ${0010|0010:?} // {PatientName} */ std::ostringstream ostr; ostr << _Std("Patient") << ": ${0010|0010:?}${NEWLINE}" << _Std("Patient ID") << ": ${0010|0020:?}"; annotation[TP_TopLeft] = ostr.str(); } { /* ${0010|0040:?} ${0010|0030} ${0010,1010} // {Sex} {BirthDate} {PatientAge} ${0010|1030:?} Kg ${0010|1020:?} m. // {PatientWeight} {PatientSize} ${0008|1030} // {Study Description} ${0008|0020} ${0008|0030} // {StudyDate} {StudyTime} ${0008|103E} // {SeriesDescription} Modalidad: ${0008|0060} // {Modality} */ std::ostringstream ostr; ostr << "${0010|0040:?} ${0010|0030::date} ${0010,1010}${NEWLINE}${0010|1030:?} Kg ${0010|1020:?} m.${NEWLINE}${0008|1030}${NEWLINE}${0008|0020::date} ${0008|0030::time}${NEWLINE}${0008|103e}${NEWLINE}" << _Std("Modality") << ": ${0008|0060}"; annotation[TP_TopRight] = ostr.str(); } { /* Imagen: ${SLICE.HEIGHT} x ${SLICE.WIDTH} ${SLICE.WL.FULLTEXT} Corte: ${SLICE.IDX} de ${SLICE.COUNT} Volumen: ${VOLUME.IDX} ${ANATOMICAL.REGION}${SLICE.VOXEL.SIZE} */ std::ostringstream ostr; ostr << _Std("Dimensions") << ": ${SLICE.WIDTH} x ${SLICE.HEIGHT}${NEWLINE}${SLICE.WL.FULLTEXT}${NEWLINE}${SLICE.IDX.FULLTEXT}${NEWLINE}${SLICE.THICKNESS.FULLTEXT}${NEWLINE}${SLICE.LOCATION.FULLTEXT}${NEWLINE}${SLICE.LATERALITY}${NEWLINE}${SLICE.VOXEL.SIZE}"; annotation[TP_BottomLeft] = ostr.str(); } { /* ${0008|0021} {0008|0031} // {SeriesDate} {Seriestime} ${0070|0081} // {ImageDescription} ${VIEW.COORDLABELS} Hecho con Ginkgo CADx Pro */ wxString appName ( wxString::FromUTF8(GNC::GCS::IEntorno::Instance()->GetApplicationName().c_str())); wxString madewith( wxString::Format(_("Made with %s"), appName.c_str())); std::ostringstream ostr; ostr << "${0008|0021::date} ${0008|0031::time}${NEWLINE}${0070|0081}${NEWLINE}${VIEW.COORDLABELS}${NEWLINE}" << madewith.ToUTF8(); annotation[TP_BottomRight] = ostr.str(); } }
std::string nextInSet(const std::string& argName, const Set& legalValues) { std::string v= next(argName); if (legalValues.find(v) == legalValues.end()) { std::ostringstream msg; msg << "Must be one of \"" << util::join(legalValues.begin(), legalValues.end(), "\", \"") << "\""; --current_; throw IllegalValueError(appName(), argName, v.c_str(), msg.str()); } return v; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QtWebEngine::initialize(); a.setAttribute(Qt::AA_DontUseNativeMenuBar,true); QString appName("RCSE"); a.setApplicationName(appName); QString version = QObject::tr("Unknown"); #ifdef VERSION_MINOR #ifdef VERSION_MAJOR #ifdef VERSION_MIDDLE version = QString("%1.%2.%3").arg(VERSION_MAJOR).arg(VERSION_MIDDLE).arg(VERSION_MINOR); #endif #endif #endif a.setApplicationVersion(version); registerQmlTypes(); QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QString locale = QLocale::system().name(); // Ressources //QResource::registerResource(appName+".rcc"); QTranslator rolisteamTranslator; rolisteamTranslator.load(":/translations/rcse_" + locale); a.installTranslator(&rolisteamTranslator); QTranslator qtTranslator; qtTranslator.load(":/translations/qt_" + locale); a.installTranslator(&qtTranslator); QStringList translationCLI; translationCLI << "-t"<<"--translation"; QStringList argList = a.arguments(); foreach(QString str, translationCLI) { int pos = argList.indexOf(str); if(pos!=-1) { if(argList.size()>pos+1) { QTranslator* cliTranslator = new QTranslator(); cliTranslator->load(argList.at(pos+1)); a.installTranslator(cliTranslator); } } }
TEST(pipelineBaseTest, common_opts) { const std::string cmd = appName(); std::string output; int stat = pdal::Utils::run_shell_command(cmd + " -h", output); EXPECT_EQ(stat, 0); // We used to accept --version as a kernel option, rather than an // application option. Make sure it now throws an error. stat = pdal::Utils::run_shell_command(cmd + " --version 2>&1", output); EXPECT_TRUE(output.find("Unexpected argument") != std::string::npos); EXPECT_NE(stat, 0); }
// replace some of the strings void KrashConfig :: expandString(QString &str, bool shell, const QString &tempFile) const { QMap<QString,QString> map; map[QString::fromLatin1("appname")] = QString::fromLatin1(appName()); map[QString::fromLatin1("execname")] = startedByKdeinit() ? QString::fromLatin1("kdeinit") : m_execname; map[QString::fromLatin1("signum")] = QString::number(signalNumber()); map[QString::fromLatin1("signame")] = signalName(); map[QString::fromLatin1("progname")] = programName(); map[QString::fromLatin1("pid")] = QString::number(pid()); map[QString::fromLatin1("tempfile")] = tempFile; if (shell) str = KMacroExpander::expandMacrosShellQuote( str, map ); else str = KMacroExpander::expandMacros( str, map ); }
QByteArray ProjectSelectionPage::encodedAppName() { // : < > * ? / \ | " are invalid on windows QByteArray tEncodedName = appName().toUtf8(); for (int i = 0; i < tEncodedName.size(); ++i) { QChar tChar(tEncodedName.at( i )); if (tChar.isDigit() || tChar.isSpace() || tChar.isLetter() || tChar == '%') continue; QByteArray tReplace = QUrl::toPercentEncoding( tChar ); tEncodedName.replace( tEncodedName.at( i ) ,tReplace ); i = i + tReplace.size() - 1; } return tEncodedName; }
int HelloServer::run(int argc, char* argv[]) { if (argc > 1) { std::cerr << appName() << ": too many arguments" << std::endl; return EXIT_FAILURE; } Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello"); Demo::HelloPtr hello = new HelloI; adapter->add(hello, communicator()->stringToIdentity("hello")); adapter->activate(); communicator()->waitForShutdown(); return EXIT_SUCCESS; }
void UpdateApplication::showNoUpdateAvailable() // ---------------------------------------------------------------------------- // Show message box: no update available // ---------------------------------------------------------------------------- { if (!show) return; QString msg = tr("<h3>%1 is up to date</h3>").arg(appName()); QString info = tr("<p>There is no new version available for download.<p>"); QMessageBox box(TaoApp->windowWidget()); box.setIconPixmap(checkmarkIcon); box.setWindowTitle(dialogTitle); box.setText(msg); box.setInformativeText(info); box.setStandardButtons(QMessageBox::Ok); box.exec(); }
AcRx::AppRetCode ArxDbgApp::exitApp() { unRegisterAppMenu(); // delete any of the notification spies that have been allocated ArxDbgUiTdmReactors::cleanUpReactors(); ArxDbgAppEditorReactor::destroyInstance(); MapTestReactor::destroyInstance(); if (m_didInit) { unRegisterCommands(); unRegisterClasses(); acutPrintf(_T("\n%s has been unloaded ... "), appName()); } return AcRx::kRetOK; }
void UpdateApplication::showDownloadSuccessful() // ---------------------------------------------------------------------------- // Show message box: download success // ---------------------------------------------------------------------------- { QString msg = tr("<h3>Download succesful</h3>"); QString info = tr("<p>%1 %2 was downloaded successfully.</p>" "<p>To complete the upgrade, you have to quit " "the application and install the new package.</p>" "<p>You may do it at your convenience.</p>") .arg(appName()).arg(remoteVer()); QMessageBox box(TaoApp->windowWidget()); setBoxMinimumWidth(box, 400); box.setIconPixmap(checkmarkIcon); box.setWindowTitle(dialogTitle); box.setText(msg); box.setInformativeText(info); box.setStandardButtons(QMessageBox::Ok); box.exec(); }
void initialise( const String& commandLine ) { try { // Initialize logger String appName(getApplicationName()); _logger = FileLogger::createDefaultAppLogger(appName, appName + "Log.txt", appName + " " + getApplicationVersion()); Logger::setCurrentLogger(_logger); Log::write("Initializing..."); // Setup app context AppContext::getInstance()->initialise(); // Load default skin //File skinpath = File::getCurrentWorkingDirectory().getChildFile("Skins/Default/"); //SkinManager::getInstance()->initialise( skinpath ); // *** TODO: This is temp test code that needs to be changed! // Login dialog should not be shown here. User needs to add music services and // we will try to login to all of them at this point without any prompt. checkLogin(); // Initialize main window _mainWindow = new MainWindow(); //_mainWindow->centreWithSize(350, 170); //_mainWindow->setVisible(true); // Testing the animator //_animator = new ComponentAnimator(); //_animator->animateComponent(_mainWindow, Rectangle(_mainWindow->getX(), _mainWindow->getY(), 500, 600), 1000, 3, 0); Log::write("Entering main loop"); } catch(Exception& ex) { if(_logger != NULL) Log::write(ex.getFullMessage()); quit(); } }
int main(int argc, const char* argv[]) { std::string exeName("TEBNFCodeGenerator"); if(argc < 4) { if(1 == argc) { std::string strPath(argv[0]); auto pos = strPath.find_last_of("/\\"); exeName = std::string::npos != pos ? strPath.substr(pos + 1) : strPath; } std::cout << "Usage: " << exeName << " <source> <destination> <name>\n" << "Arguments:\n" << " source - Path of file containing TEBNF grammar, including file name.\n" << " destination - Path of the location on disk to write generated files.\n" << " name - Name to give to the generated application.\n"; } else { try { std::string srcFilePath(argv[1]); std::string destDirPath(argv[2]); std::string appName(argv[3]); Utils::Logger::setup(srcFilePath); //Setup static logger. Utils::Logger::log("\n--------- TEBNF Code Generator v" + Utils::getTEBNFVersion() + " ---------\n"); Reader::read(srcFilePath); Scanner::scan(Reader::getFileText()); Parser::parse(); Generator::generate(destDirPath, appName); return EXIT_SUCCESS; } catch(std::exception& ex) { std::cout << std::string(ex.what()) << std::endl; } } return EXIT_FAILURE; }