Changeset View
Changeset View
Standalone View
Standalone View
src/settings/ProfileSettings.cpp
Context not available. | |||||
55 | sessionTable->setItemDelegateForColumn(ShortcutColumn, new ShortcutItemDelegate(this)); | 55 | sessionTable->setItemDelegateForColumn(ShortcutColumn, new ShortcutItemDelegate(this)); | ||
---|---|---|---|---|---|
56 | sessionTable->setEditTriggers(sessionTable->editTriggers() | QAbstractItemView::SelectedClicked); | 56 | sessionTable->setEditTriggers(sessionTable->editTriggers() | QAbstractItemView::SelectedClicked); | ||
57 | 57 | | |||
58 | // double clicking the profile name opens the profile edit dialog | ||||
59 | connect(sessionTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(doubleClicked(QModelIndex))); | ||||
60 | | ||||
58 | // populate the table with profiles | 61 | // populate the table with profiles | ||
59 | populateTable(); | 62 | populateTable(); | ||
60 | 63 | | |||
Context not available. | |||||
90 | QKeySequence sequence = QKeySequence::fromString(item->text()); | 93 | QKeySequence sequence = QKeySequence::fromString(item->text()); | ||
91 | ProfileManager::instance()->setShortcut(item->data(ShortcutRole).value<Profile::Ptr>(), | 94 | ProfileManager::instance()->setShortcut(item->data(ShortcutRole).value<Profile::Ptr>(), | ||
92 | sequence); | 95 | sequence); | ||
93 | } else if (item->column() == ProfileNameColumn) { | | |||
94 | QString newName = item->text(); | | |||
95 | Profile::Ptr profile = item->data(ProfileKeyRole).value<Profile::Ptr>(); | | |||
96 | QString oldName = profile->name(); | | |||
97 | | ||||
98 | if (newName != oldName) { | | |||
99 | QHash<Profile::Property, QVariant> properties; | | |||
100 | properties.insert(Profile::Name, newName); | | |||
101 | properties.insert(Profile::UntranslatedName, newName); | | |||
102 | | ||||
103 | ProfileManager::instance()->changeProfile(profile, properties); | | |||
104 | } | | |||
105 | } | 96 | } | ||
106 | } | 97 | } | ||
107 | 98 | | |||
Context not available. | |||||
144 | if (!profile->icon().isEmpty()) | 135 | if (!profile->icon().isEmpty()) | ||
145 | items[ProfileNameColumn]->setIcon(QIcon::fromTheme(profile->icon())); | 136 | items[ProfileNameColumn]->setIcon(QIcon::fromTheme(profile->icon())); | ||
146 | items[ProfileNameColumn]->setData(QVariant::fromValue(profile), ProfileKeyRole); | 137 | items[ProfileNameColumn]->setData(QVariant::fromValue(profile), ProfileKeyRole); | ||
147 | items[ProfileNameColumn]->setToolTip(i18nc("@info:tooltip", "Click to rename profile")); | 138 | // only allow renaming the profile from the edit profile dialog | ||
139 | // so as to use ProfileManager::checkProfileName() | ||||
140 | items[ProfileNameColumn]->setEditable(false); | ||||
148 | 141 | | |||
149 | // Favorite Status | 142 | // Favorite Status | ||
150 | const bool isFavorite = ProfileManager::instance()->findFavorites().contains(profile); | 143 | const bool isFavorite = ProfileManager::instance()->findFavorites().contains(profile); | ||
Context not available. | |||||
161 | items[ShortcutColumn]->setData(QVariant::fromValue(profile), ShortcutRole); | 154 | items[ShortcutColumn]->setData(QVariant::fromValue(profile), ShortcutRole); | ||
162 | items[ShortcutColumn]->setToolTip(i18nc("@info:tooltip", "Double click to change shortcut")); | 155 | items[ShortcutColumn]->setToolTip(i18nc("@info:tooltip", "Double click to change shortcut")); | ||
163 | } | 156 | } | ||
157 | | ||||
158 | void ProfileSettings::doubleClicked(const QModelIndex &index) | ||||
159 | { | ||||
160 | QStandardItem *item = _sessionModel->itemFromIndex(index); | ||||
161 | if (item->column() == ProfileNameColumn) { | ||||
162 | editSelected(); | ||||
163 | } | ||||
164 | } | ||||
165 | | ||||
164 | void ProfileSettings::addItems(const Profile::Ptr profile) | 166 | void ProfileSettings::addItems(const Profile::Ptr profile) | ||
165 | { | 167 | { | ||
166 | if (profile->isHidden()) | 168 | if (profile->isHidden()) | ||
Context not available. |