forked from qt-creator/qt-creator
LanguageClient: make client selector exclusive
Change-Id: Icc97a3d7a651881613ba91b60db8784274462424 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -218,13 +218,24 @@ void updateEditorToolBar(Core::IEditor *editor)
|
|||||||
const QIcon icon = Utils::Icon({{":/languageclient/images/languageclient.png",
|
const QIcon icon = Utils::Icon({{":/languageclient/images/languageclient.png",
|
||||||
Utils::Theme::IconsBaseColor}})
|
Utils::Theme::IconsBaseColor}})
|
||||||
.icon();
|
.icon();
|
||||||
actions[widget] = widget->toolBar()->addAction(icon, client->name(), [document]() {
|
actions[widget] = widget->toolBar()->addAction(
|
||||||
|
icon, client->name(), [document]() {
|
||||||
auto menu = new QMenu;
|
auto menu = new QMenu;
|
||||||
for (auto client : LanguageClientManager::clientsSupportingDocument(document))
|
auto *clientsGroup = new QActionGroup(menu);
|
||||||
menu->addAction(client->name(), [client = QPointer<Client>(client), document]() {
|
clientsGroup->setExclusive(true);
|
||||||
if (client)
|
for (auto client : LanguageClientManager::clientsSupportingDocument(document)) {
|
||||||
|
auto action = clientsGroup->addAction(client->name());
|
||||||
|
auto reopen = [action, client = QPointer<Client>(client), document]() {
|
||||||
|
if (!client)
|
||||||
|
return;
|
||||||
LanguageClientManager::reOpenDocumentWithClient(document, client);
|
LanguageClientManager::reOpenDocumentWithClient(document, client);
|
||||||
});
|
action->setChecked(true);
|
||||||
|
};
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(client == LanguageClientManager::clientForDocument(document));
|
||||||
|
QObject::connect(action, &QAction::triggered, reopen);
|
||||||
|
}
|
||||||
|
menu->addActions(clientsGroup->actions());
|
||||||
menu->addAction("Manage...", []() {
|
menu->addAction("Manage...", []() {
|
||||||
Core::ICore::showOptionsDialog(Constants::LANGUAGECLIENT_SETTINGS_PAGE);
|
Core::ICore::showOptionsDialog(Constants::LANGUAGECLIENT_SETTINGS_PAGE);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user