| 173 | } |
| 174 | |
| 175 | void ScriptManagerWidget::treeSelectionChanged() |
| 176 | { |
| 177 | details->setPlainText(QString()); |
| 178 | |
| 179 | QTreeWidget * tree = scriptTabs->currentWidget() == standaloneTab ? standaloneTree : hookTree; |
| 180 | QList<QTreeWidgetItem*> selection = tree->selectedItems(); |
| 181 | if (selection.size() != 1) |
| 182 | return; |
| 183 | |
| 184 | if (selection[0]->type() != kScriptType) |
| 185 | return; |
| 186 | |
| 187 | Tw::Scripting::ScriptObject * so = static_cast<Tw::Scripting::ScriptObject*>(selection[0]->data(0, Qt::UserRole).value<void*>()); |
| 188 | if (!so) |
| 189 | return; |
| 190 | |
| 191 | QString rows; |
| 192 | addDetailsRow(rows, tr("Name: "), so->getTitle()); |
| 193 | addDetailsRow(rows, tr("Context: "), so->getContext()); |
| 194 | addDetailsRow(rows, tr("Description: "), so->getDescription()); |
| 195 | addDetailsRow(rows, tr("Author: "), so->getAuthor()); |
| 196 | addDetailsRow(rows, tr("Version: "), so->getVersion()); |
| 197 | addDetailsRow(rows, tr("Shortcut: "), so->getKeySequence().toString()); |
| 198 | addDetailsRow(rows, tr("File: "), QFileInfo(so->getFilename()).fileName()); |
| 199 | |
| 200 | #if QT_VERSION < QT_VERSION_CHECK(6, 3, 0) |
| 201 | const Tw::Scripting::ScriptLanguageInterface * sli = qobject_cast<Tw::Scripting::ScriptLanguageInterface*>(so->getScriptLanguagePlugin()); |
| 202 | #else |
| 203 | const Tw::Scripting::ScriptLanguageInterface * sli = qobject_cast<const Tw::Scripting::ScriptLanguageInterface*>(so->getScriptLanguagePlugin()); |
| 204 | #endif |
| 205 | if(sli) { |
| 206 | QString url = sli->scriptLanguageURL(); |
| 207 | QString str = sli->scriptLanguageName(); |
| 208 | if (!url.isEmpty()) |
| 209 | str = QString::fromLatin1("<a href=\"%1\">%2</a>").arg(url, str); |
| 210 | addDetailsRow(rows, tr("Language: "), str); |
| 211 | } |
| 212 | |
| 213 | if (so->getType() == Tw::Scripting::Script::ScriptHook) |
| 214 | addDetailsRow(rows, tr("Hook: "), so->getHook()); |
| 215 | |
| 216 | details->setHtml(QString::fromLatin1("<table>%1</table").arg(rows)); |
| 217 | } |
| 218 | |
| 219 | void ScriptManagerWidget::addDetailsRow(QString& html, const QString & label, const QString & value) |
| 220 | { |
nothing calls this directly
no test coverage detected