//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void Profiler_Imp::Start(int id) { Profile::Ptr profile = nullptr; for (auto& x : m_profiles) { if (x->GetID() == id) { profile = x; } } if (profile == nullptr) { profile = make_shared<Profile>(id); m_profiles.push_back(profile); } profile->GetCurrent()->SetStartTime(asd::GetTime()); #if _WIN32 profile->GetCurrent()->SetProcessorNumber(GetCurrentProcessorNumber()); #elif defined(__APPLE__) // sched_getcpuがないようなので代用。よりよいものがあれば差し替えてください。 profile->GetCurrent()->SetProcessorNumber( std::hash<std::thread::id>()(std::this_thread::get_id())); #else profile->GetCurrent()->SetProcessorNumber(sched_getcpu()); #endif }
QString ProfilePlotView::profileLabel(Profile::Ptr profile) { if (profile->name()) return QString::fromStdString(profile->name().get()); if (profile->computer()) { if (profile->computer()->name()) return QString::fromStdString(profile->computer()->name().get()); if (profile->computer()->model()) { if (profile->computer()->manufacturer()) { return QString("%1 %2") .arg(QString::fromStdString(profile->computer()->manufacturer().get())) .arg(QString::fromStdString(profile->computer()->model().get())); } else { return QString::fromStdString(profile->computer()->model().get()); } } } return "Unknown Profile"; }
void ProfileList::updateAction(QAction* action , Profile::Ptr info) { Q_ASSERT(action); Q_ASSERT(info); action->setText(info->name()); action->setIcon(KIcon(info->icon())); }
void EditProfileDialog::setupAppearancePage(const Profile::Ptr info) { ColorSchemeViewDelegate* delegate = new ColorSchemeViewDelegate(this); _ui->colorSchemeList->setItemDelegate(delegate); _colorSchemeAnimationTimeLine = new QTimeLine( 500 , this ); delegate->setEntryTimeLine(_colorSchemeAnimationTimeLine); connect( _colorSchemeAnimationTimeLine , SIGNAL(valueChanged(qreal)) , this , SLOT(colorSchemeAnimationUpdate()) ); _ui->transparencyWarningWidget->setVisible(false); _ui->editColorSchemeButton->setEnabled(false); _ui->removeColorSchemeButton->setEnabled(false); // setup color list updateColorSchemeList(true); _ui->colorSchemeList->setMouseTracking(true); _ui->colorSchemeList->installEventFilter(this); _ui->colorSchemeList->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); connect( _ui->colorSchemeList->selectionModel() , SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)) , this , SLOT(colorSchemeSelected()) ); connect( _ui->colorSchemeList , SIGNAL(entered(const QModelIndex&)) , this , SLOT(previewColorScheme(const QModelIndex&)) ); updateColorSchemeButtons(); connect( _ui->editColorSchemeButton , SIGNAL(clicked()) , this , SLOT(editColorScheme()) ); connect( _ui->removeColorSchemeButton , SIGNAL(clicked()) , this , SLOT(removeColorScheme()) ); connect( _ui->newColorSchemeButton , SIGNAL(clicked()) , this , SLOT(newColorScheme()) ); // setup font preview bool antialias = info->property<bool>(Profile::AntiAliasFonts); QFont font = info->font(); if (!antialias) font.setStyleStrategy(QFont::NoAntialias); _ui->fontPreviewLabel->installEventFilter(this); _ui->fontPreviewLabel->setFont(font); _ui->fontSizeSlider->setValue( font.pointSize() ); _ui->fontSizeSlider->setMinimum( KGlobalSettings::smallestReadableFont().pointSize() ); connect( _ui->fontSizeSlider , SIGNAL(valueChanged(int)) , this , SLOT(setFontSize(int)) ); connect( _ui->editFontButton , SIGNAL(clicked()) , this , SLOT(showFontDialog()) ); // setup font smoothing _ui->antialiasTextButton->setChecked(antialias); connect( _ui->antialiasTextButton , SIGNAL(toggled(bool)) , this , SLOT(setAntialiasText(bool)) ); }
void EditProfileDialog::setupGeneralPage(const Profile::Ptr info) { // basic profile options _ui->profileNameEdit->setText( info->name() ); ShellCommand command( info->command() , info->arguments() ); _ui->commandEdit->setText( command.fullCommand() ); KUrlCompletion* exeCompletion = new KUrlCompletion(KUrlCompletion::ExeCompletion); exeCompletion->setParent(this); exeCompletion->setDir(QString()); _ui->commandEdit->setCompletionObject( exeCompletion ); _ui->initialDirEdit->setText( info->defaultWorkingDirectory() ); KUrlCompletion* dirCompletion = new KUrlCompletion(KUrlCompletion::DirCompletion); dirCompletion->setParent(this); _ui->initialDirEdit->setCompletionObject( dirCompletion ); _ui->initialDirEdit->setClearButtonShown(true); _ui->dirSelectButton->setIcon( KIcon("folder-open") ); _ui->iconSelectButton->setIcon( KIcon(info->icon()) ); _ui->startInSameDirButton->setChecked(info->property<bool>(Profile::StartInCurrentSessionDir)); // window options _ui->showMenuBarButton->setChecked( info->property<bool>(Profile::ShowMenuBar) ); // signals and slots connect( _ui->dirSelectButton , SIGNAL(clicked()) , this , SLOT(selectInitialDir()) ); connect( _ui->iconSelectButton , SIGNAL(clicked()) , this , SLOT(selectIcon()) ); connect( _ui->startInSameDirButton , SIGNAL(toggled(bool)) , this , SLOT(startInSameDir(bool))); connect( _ui->profileNameEdit , SIGNAL(textChanged(const QString&)) , this , SLOT(profileNameChanged(const QString&)) ); connect( _ui->initialDirEdit , SIGNAL(textChanged(const QString&)) , this , SLOT(initialDirChanged(const QString&)) ); connect(_ui->commandEdit , SIGNAL(textChanged(const QString&)) , this , SLOT(commandChanged(const QString&)) ); connect(_ui->showMenuBarButton , SIGNAL(toggled(bool)) , this , SLOT(showMenuBar(bool)) ); connect(_ui->environmentEditButton , SIGNAL(clicked()) , this , SLOT(showEnvironmentEditor()) ); }
void ManageProfilesDialog::itemDataChanged(QStandardItem* item) { if (item->column() == ShortcutColumn) { QKeySequence sequence = QKeySequence::fromString(item->text()); ProfileManager::instance()->setShortcut(item->data(ShortcutRole).value<Profile::Ptr>(), sequence); } else if (item->column() == ProfileNameColumn) { QString newName = item->text(); Profile::Ptr profile = item->data(ProfileKeyRole).value<Profile::Ptr>(); QString oldName = profile->name(); if (newName != oldName) { QHash<Profile::Property, QVariant> properties; properties.insert(Profile::Name, newName); properties.insert(Profile::UntranslatedName, newName); ProfileManager::instance()->changeProfile(profile, properties); } } }
void ManageProfilesDialog::addItems(const Profile::Ptr profile) { if (profile->isHidden()) return; QList<QStandardItem*> items; for (int i = 0; i < 3; i++) items << new QStandardItem; updateItemsForProfile(profile, items); _sessionModel->appendRow(items); }
void ProfileSettings::addItems(const Profile::Ptr profile) { if (profile->isHidden()) return; QList<QStandardItem*> items; items.reserve(3); for (int i = 0; i < 3; i++) items.append(new QStandardItem); updateItemsForProfile(profile, items); _sessionModel->appendRow(items); }
// Verify the correct file name is created from the untranslatedname void ProfileTest::testProfileFileNames() { Profile::Ptr profile = Profile::Ptr(new Profile); QFileInfo fileInfo; ProfileWriter* writer = new KDE4ProfileWriter; profile->setProperty(Profile::UntranslatedName, "Indiana"); fileInfo.setFile(writer->getPath(profile)); QCOMPARE(fileInfo.fileName(), QString("Indiana.profile")); profile->setProperty(Profile::UntranslatedName, "Old Paris"); fileInfo.setFile(writer->getPath(profile)); QCOMPARE(fileInfo.fileName(), QString("Old Paris.profile")); /* FIXME: deal w/ file systems that are case-insensitive This leads to confusion as both Test and test can appear in the Manager Profile dialog while really there is only 1 test.profile file. Suggestions: all lowercase, testing the file system, ... */ /* profile->setProperty(Profile::UntranslatedName, "New Profile"); fileInfo.setFile(writer->getPath(profile)); QCOMPARE(fileInfo.fileName(), QString("new profile.profile")); */ /* FIXME: don't allow certain characters in file names Consider: ,^@=+{}[]~!?:&*\"|#%<>$\"'();`'/\ Suggestions: changing them all to _, just remove them, ... Bug 315086 comes from a user using / in the profile name - multiple issues there. */ /* profile->setProperty(Profile::UntranslatedName, "new/profile"); fileInfo.setFile(writer->getPath(profile)); QCOMPARE(fileInfo.fileName(), QString("new_profile.profile")); */ delete writer; }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void Profiler_Imp::End(int id) { Profile::Ptr profile = nullptr; for (auto& x : m_profiles) { if (x->GetID() == id) { profile = x; } } if (profile == nullptr) { #if _WIN32 throw exception("対応するStartがありません。"); #else assert(0); #endif } profile->GetCurrent()->SetEndTime(asd::GetTime()); profile->Archive(); }
void ManageProfilesDialog::updateItemsForProfile(const Profile::Ptr profile, QList<QStandardItem*>& items) const { // Profile Name items[ProfileNameColumn]->setText(profile->name()); if (!profile->icon().isEmpty()) items[ProfileNameColumn]->setIcon(KIcon(profile->icon())); items[ProfileNameColumn]->setData(QVariant::fromValue(profile), ProfileKeyRole); items[ProfileNameColumn]->setToolTip(i18nc("@info:tooltip", "Click to rename profile")); // Favorite Status const bool isFavorite = ProfileManager::instance()->findFavorites().contains(profile); if (isFavorite) items[FavoriteStatusColumn]->setData(KIcon("dialog-ok-apply"), Qt::DecorationRole); else items[FavoriteStatusColumn]->setData(KIcon(), Qt::DecorationRole); items[FavoriteStatusColumn]->setData(QVariant::fromValue(profile), ProfileKeyRole); items[FavoriteStatusColumn]->setToolTip(i18nc("@info:tooltip", "Click to toggle status")); // Shortcut QString shortcut = ProfileManager::instance()->shortcut(profile).toString(); items[ShortcutColumn]->setText(shortcut); items[ShortcutColumn]->setData(QVariant::fromValue(profile), ShortcutRole); items[ShortcutColumn]->setToolTip(i18nc("@info:tooltip", "Double click to change shortcut")); }
void TransferWorker::parse_dives(Driver::Ptr driver, const dive_data_t & dives) { IMixFinder::Ptr mf = boost::dynamic_pointer_cast<IMixFinder>(m_session->finder<Mix>()); Mix::Ptr air = mf->findByName("Air"); parser_data data; data.mixfinder = mf; // Parse the Dives dive_data_t::const_iterator it; for (it = dives.begin(); it != dives.end(); it++) { // Setup Parser Data data.dive.reset(new Dive); data.mixes.clear(); data.profile.clear(); data.vendor.clear(); data.haswp = false; data.curmix = air; // Parse the Header and Profile driver->parse(it->first, & parse_header, & parse_profile, & data); // Append the final Waypoint if (data.haswp) data.profile.push_back(data.curwp); // Update Dive Data data.dive->setComputer(m_dc); // Set the Dive Mix as the first Mix in the profile if (data.haswp) data.dive->setMix(data.profile.begin()->mix); // Create Profile Profile::Ptr profile = Profile::Ptr(new Profile); profile->setComputer(m_dc); profile->setDive(data.dive); profile->setImported(time(NULL)); profile->setProfile(data.profile); profile->setRawProfile(it->first); profile->setVendor(json_encode(data.vendor)); // Emit Parsed Dive emit parsedDive(profile); } }
void EditProfileDialog::setProfile(Profile::Ptr profile) { _profileKey = profile; Q_ASSERT( profile ); // update caption updateCaption(profile->name()); // mark each page of the dialog as out of date // and force an update of the currently visible page // // the other pages will be updated as necessary _pageNeedsUpdate.fill(true); preparePage( _ui->tabWidget->currentIndex() ); if ( _tempProfile ) { _tempProfile = new Profile; } }
QString KDE4ProfileWriter::getPath(const Profile::Ptr profile) { // both location have trailing slash static const QString localDataLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/konsole/"); static const QString systemDataLocation = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).last() + QStringLiteral("konsole/"); const QString candidateLocalPath = localDataLocation + profile->untranslatedName() + ".profile"; QString newPath; // when the path property is not set, it means the profile has just // been created in memory and has never been saved into disk before. // // use "name.profile" as filename and save it under $KDEHOME if (!profile->isPropertySet(Profile::Path)) { return candidateLocalPath; } // for a system wide profile, save the modified version as // a local profile under $KDEHOME if (profile->path().startsWith(systemDataLocation)) { return candidateLocalPath; } // for a local profile, use its existing path if (profile->path().startsWith(localDataLocation)) { newPath = profile->path(); } else { // for the ad-hoc profiles in non-standard places // // * if its path is writable for user, use its existing path // * if its path is not writable for user, save it under $KDEHOME // QFileInfo fileInfo(profile->path()); if (fileInfo.isWritable()) { newPath = profile->path(); } else { newPath = candidateLocalPath; } } return newPath; }
void KDE4ProfileWriter::writeProperties(KConfig& config, const Profile::Ptr profile, const Profile::PropertyInfo* properties) { const char* groupName = 0; KConfigGroup group; while (properties->name != 0) { if (properties->group != 0) { if (groupName == 0 || qstrcmp(groupName, properties->group) != 0) { group = config.group(properties->group); groupName = properties->group; } if (profile->isPropertySet(properties->property)) group.writeEntry(QString(properties->name), profile->property<QVariant>(properties->property)); } properties++; } }
std::list<Persistent::Ptr> ProfileMapper::cascade_add(Persistent::Ptr p) { std::list<Persistent::Ptr> result; Profile::Ptr o = downcast(p); if (! o) return result; if (o->computer()) result.push_back(o->computer()); if (o->dive()) result.push_back(o->dive()); std::set<Mix::Ptr> mixes; std::list<waypoint>::const_iterator it; for (it = o->profile().begin(); it != o->profile().end(); it++) mixes.insert(it->mix); std::set<Mix::Ptr>::iterator it2; for (it2 = mixes.begin(); it2 != mixes.end(); it2++) result.push_back(* it2); return result; }
bool KDE4ProfileWriter::writeProfile(const QString& path , const Profile::Ptr profile) { KConfig config(path, KConfig::NoGlobals); KConfigGroup general = config.group(GENERAL_GROUP); // Parent profile if set, when loading the profile in future, the parent // must be loaded as well if it exists. if (profile->parent()) general.writeEntry("Parent", profile->parent()->path()); if (profile->isPropertySet(Profile::Command) || profile->isPropertySet(Profile::Arguments)) general.writeEntry("Command", ShellCommand(profile->command(), profile->arguments()).fullCommand()); // Write remaining properties writeProperties(config, profile, Profile::DefaultPropertyNames); return true; }
void Application::createTabFromArgs(KCmdLineArgs* args, MainWindow* window, const QHash<QString, QString>& tokens) { const QString& title = tokens["title"]; const QString& command = tokens["command"]; const QString& profile = tokens["profile"]; const QString& workdir = tokens["workdir"]; Profile::Ptr baseProfile; if (!profile.isEmpty()) { baseProfile = ProfileManager::instance()->loadProfile(profile); } if (!baseProfile) { // fallback to default profile baseProfile = ProfileManager::instance()->defaultProfile(); } Profile::Ptr newProfile = Profile::Ptr(new Profile(baseProfile)); newProfile->setHidden(true); // FIXME: the method of determining whethter to use newProfile does not // scale well when we support more fields in the future bool shouldUseNewProfile = false; if (!command.isEmpty()) { newProfile->setProperty(Profile::Command, command); newProfile->setProperty(Profile::Arguments, command.split(' ')); shouldUseNewProfile = true; } if (!title.isEmpty()) { newProfile->setProperty(Profile::LocalTabTitleFormat, title); newProfile->setProperty(Profile::RemoteTabTitleFormat, title); shouldUseNewProfile = true; } if (args->isSet("workdir")) { newProfile->setProperty(Profile::Directory, args->getOption("workdir")); shouldUseNewProfile = true; } if (!workdir.isEmpty()) { newProfile->setProperty(Profile::Directory, workdir); shouldUseNewProfile = true; } // Create the new session Profile::Ptr theProfile = shouldUseNewProfile ? newProfile : baseProfile; Session* session = window->createSession(theProfile, QString()); if (!args->isSet("close")) { session->setAutoClose(false); } if (!window->testAttribute(Qt::WA_Resized)) { window->resize(window->sizeHint()); } // FIXME: this ugly hack here is to make the session start running, so that // its tab title is displayed as expected. // // This is another side effect of the commit fixing BKO 176902. window->show(); window->hide(); }
//! @brief Unlink this Object to the Owning Object virtual void unlink(Persistent::Ptr d, Persistent::Ptr obj) { Dive::Ptr dive = boost::dynamic_pointer_cast<Dive>(obj); Profile::Ptr profile = boost::dynamic_pointer_cast<Profile>(d); profile->setDive(boost::none); }
static bool profileNameLessThan(const Profile::Ptr& p1, const Profile::Ptr& p2) { return QString::localeAwareCompare(p1->name(), p2->name()) <= 0; }
static bool profileIndexLessThan(const Profile::Ptr& p1, const Profile::Ptr& p2) { return p1->menuIndexAsInt() <= p2->menuIndexAsInt(); }
Profile::Ptr ProfileManager::loadProfile(const QString& shortPath) { // the fallback profile has a 'special' path name, "FALLBACK/" if (shortPath == _fallbackProfile->path()) return _fallbackProfile; QString path = shortPath; // add a suggested suffix and relative prefix if missing QFileInfo fileInfo(path); if (fileInfo.isDir()) return Profile::Ptr(); if (fileInfo.suffix() != QLatin1String("profile")) path.append(".profile"); if (fileInfo.path().isEmpty() || fileInfo.path() == QLatin1String(".")) path.prepend(QLatin1String("konsole") + QDir::separator()); // if the file is not an absolute path, look it up if (!fileInfo.isAbsolute()) path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, path); // if the file is not found, return immediately if (path.isEmpty()) { return Profile::Ptr(); } // check that we have not already loaded this profile foreach(const Profile::Ptr& profile, _profiles) { if (profile->path() == path) return profile; } // guard to prevent problems if a profile specifies itself as its parent // or if there is recursion in the "inheritance" chain // (eg. two profiles, A and B, specifying each other as their parents) static QStack<QString> recursionGuard; PopStackOnExit<QString> popGuardOnExit(recursionGuard); if (recursionGuard.contains(path)) { qWarning() << "Ignoring attempt to load profile recursively from" << path; return _fallbackProfile; } else { recursionGuard.push(path); } // load the profile ProfileReader* reader = new KDE4ProfileReader; Profile::Ptr newProfile = Profile::Ptr(new Profile(fallbackProfile())); newProfile->setProperty(Profile::Path, path); QString parentProfilePath; bool result = reader->readProfile(path, newProfile, parentProfilePath); if (!parentProfilePath.isEmpty()) { Profile::Ptr parentProfile = loadProfile(parentProfilePath); newProfile->setParent(parentProfile); } delete reader; if (!result) { qWarning() << "Could not load profile from " << path; return Profile::Ptr(); } else { addProfile(newProfile); return newProfile; } }
void ProfileMapper::bindUpdate(statement::ptr s, Persistent::Ptr p) const { Profile::Ptr o = downcast(p); if (o->dive()) s->bind(2, o->dive()->id()); else s->bind(2); if (o->computer()) s->bind(3, o->computer()->id()); else s->bind(3); if (o->profile().empty()) s->bind(5); else s->bind(5, profileToJSON(o->profile())); s->bind(4, o->name()); s->bind(6, o->vendor()); s->bind(7, o->imported()); s->bind(8, o->raw_profile()); }