Commit 2c5acabc authored by Urs Wolfer's avatar Urs Wolfer

Feature: show bookmark name instead of URL when opening a session from bookmarks.

Based on a patch by deadeyes, thanks.
FEATURE:203310

svn path=/trunk/KDE/kdenetwork/krdc/; revision=1097090
parent 45608089
......@@ -285,7 +285,7 @@ void MainWindow::restoreOpenSessions()
}
}
void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConnected)
void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConnected, const QString &tabName)
{
m_switchFullscreenWhenConnected = switchFullscreenWhenConnected;
......@@ -353,7 +353,7 @@ void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConn
if (indexOfNewConnectionWidget >= 0)
m_tabWidget->removeTab(indexOfNewConnectionWidget);
const int newIndex = m_tabWidget->addTab(scrollArea, KIcon("krdc"), url.prettyUrl(KUrl::RemoveTrailingSlash));
const int newIndex = m_tabWidget->addTab(scrollArea, KIcon("krdc"), tabName.isEmpty() ? url.prettyUrl(KUrl::RemoveTrailingSlash) : tabName);
m_tabWidget->setCurrentIndex(newIndex);
tabChanged(newIndex); // force to update m_currentRemoteView (tabChanged is not emitted when start page has been disabled)
......@@ -362,9 +362,10 @@ void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConn
void MainWindow::openFromRemoteDesktopsModel(const QModelIndex &index)
{
const QString data = index.data(10001).toString();
if (!data.isEmpty()) {
const KUrl url(data);
const QString urlString = index.data(10001).toString();
const QString nameString = index.data(10003).toString();
if (!urlString.isEmpty()) {
const KUrl url(urlString);
// first check if url has already been opened; in case show the tab
for (int i = 0; i < m_remoteViewList.count(); ++i) {
if (m_remoteViewList.at(i)->url() == url) {
......@@ -372,7 +373,7 @@ void MainWindow::openFromRemoteDesktopsModel(const QModelIndex &index)
return;
}
}
newConnection(url);
newConnection(url, false, nameString);
}
}
......@@ -679,7 +680,7 @@ void MainWindow::showConnectionContextMenu(const QPoint &pos)
} else if (selectedAction == renameAction) {
//TODO: use inline editor if possible
const QString newTitle = QInputDialog::getText(this, i18n("Rename %1", title), i18n("Rename %1 to", title));
if (!newTitle.isNull()) {
if (!newTitle.isEmpty()) {
BookmarkManager::updateTitle(m_bookmarkManager->getManager(), url, newTitle);
}
} else if (selectedAction == settingsAction) {
......
......@@ -67,7 +67,7 @@ public:
int currentRemoteView() const;
public slots:
void newConnection(const KUrl &newUrl = KUrl(), bool switchFullscreenWhenConnected = false);
void newConnection(const KUrl &newUrl = KUrl(), bool switchFullscreenWhenConnected = false, const QString &tabName = QString());
protected:
virtual void closeEvent(QCloseEvent *event);
......
......@@ -150,6 +150,9 @@ QVariant RemoteDesktopsModel::data(const QModelIndex &index, int role) const
case 10002: //filter
return item.url + item.title; // return both uservisible and data
case 10003: //url for dockwidget
return item.title;
default:
return QVariant();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment