| 1935 | } |
| 1936 | |
| 1937 | void MainWindow::FillRemotesMenu(QMenu *menu, bool includeLocalhost) |
| 1938 | { |
| 1939 | menu->clear(); |
| 1940 | |
| 1941 | rdcarray<RemoteHost> hosts = m_Ctx.Config().GetRemoteHosts(); |
| 1942 | |
| 1943 | int idx = 1; |
| 1944 | |
| 1945 | for(int i = 0; i < hosts.count(); i++) |
| 1946 | { |
| 1947 | RemoteHost host = hosts[i]; |
| 1948 | |
| 1949 | // add localhost at the end, skip invalid hosts |
| 1950 | if(host.IsLocalhost() || !host.IsValid()) |
| 1951 | continue; |
| 1952 | |
| 1953 | QAction *action = new QAction(menu); |
| 1954 | |
| 1955 | action->setIcon(host.IsServerRunning() && !host.IsVersionMismatch() ? Icons::tick() |
| 1956 | : Icons::cross()); |
| 1957 | if(host.IsConnected()) |
| 1958 | action->setText(tr("%1 (Connected)").arg(host.Name())); |
| 1959 | else if(host.IsServerRunning() && host.IsVersionMismatch()) |
| 1960 | action->setText(tr("%1 (%2)").arg(host.Name(), host.VersionMismatchError())); |
| 1961 | else if(host.IsServerRunning() && host.IsBusy()) |
| 1962 | action->setText(tr("%1 (Busy)").arg(host.Name())); |
| 1963 | else if(host.IsServerRunning()) |
| 1964 | action->setText(tr("%1 (Online)").arg(host.Name())); |
| 1965 | else |
| 1966 | action->setText(tr("%1 (Offline)").arg(host.Name())); |
| 1967 | |
| 1968 | action->setText(lit("%1: %2").arg(idx++).arg(action->text())); |
| 1969 | |
| 1970 | QObject::connect(action, &QAction::triggered, this, &MainWindow::switchContext); |
| 1971 | action->setData(i); |
| 1972 | |
| 1973 | // don't allow switching to the connected host |
| 1974 | if(host.IsConnected()) |
| 1975 | action->setEnabled(false); |
| 1976 | |
| 1977 | menu->addAction(action); |
| 1978 | } |
| 1979 | |
| 1980 | if(includeLocalhost) |
| 1981 | { |
| 1982 | QAction *localContext = new QAction(menu); |
| 1983 | |
| 1984 | localContext->setText(tr("Local")); |
| 1985 | localContext->setIcon(Icons::house()); |
| 1986 | |
| 1987 | QObject::connect(localContext, &QAction::triggered, this, &MainWindow::switchContext); |
| 1988 | localContext->setData(-1); |
| 1989 | |
| 1990 | menu->addAction(localContext); |
| 1991 | } |
| 1992 | } |
| 1993 | |
| 1994 | void MainWindow::setRemoteHost(int hostIdx) |
nothing calls this directly
no test coverage detected