summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Hindenburg <kurt.hindenburg@gmail.com>2011-02-14 02:29:15 (GMT)
committerKurt Hindenburg <kurt.hindenburg@gmail.com>2011-03-01 04:09:25 (GMT)
commit86ff99b3c1c156fc4d55beed750cc5eb66f61b3d (patch)
tree432efea67cf921efee02f2a98fbd7d3d1d499a61
parent249dc86a1b6239bb4509d13157bfd9ebe5847fc2 (diff)
Set correct focus in the "rename tab" dialog.
Currently, the OK button has the focus upon startup. After patch, the user doesn't need to remember if they need to adjust the remote or local title. Patch by Sebastian Kühn http://git.reviewboard.kde.org/r/100642/ (cherry picked from commit acd507e1a55446c6d46d1a2cdbb32a516ae1a021)
-rw-r--r--src/RenameTabsDialog.cpp9
-rw-r--r--src/RenameTabsDialog.h3
-rw-r--r--src/Session.cpp8
-rw-r--r--src/Session.h7
-rw-r--r--src/SessionController.cpp6
5 files changed, 33 insertions, 0 deletions
diff --git a/src/RenameTabsDialog.cpp b/src/RenameTabsDialog.cpp
index 2ecd417..c70cc8a 100644
--- a/src/RenameTabsDialog.cpp
+++ b/src/RenameTabsDialog.cpp
@@ -56,6 +56,15 @@ RenameTabsDialog::~RenameTabsDialog()
delete _ui;
}
+void RenameTabsDialog::focusTabTitleText()
+{
+ _ui->tabTitleEdit->setFocus();
+}
+
+void RenameTabsDialog::focusRemoteTabTitleText()
+{
+ _ui->remoteTabTitleEdit->setFocus();
+}
void RenameTabsDialog::setTabTitleText(const QString& text)
{
diff --git a/src/RenameTabsDialog.h b/src/RenameTabsDialog.h
index 734f270..157e6a9 100644
--- a/src/RenameTabsDialog.h
+++ b/src/RenameTabsDialog.h
@@ -49,6 +49,9 @@ public:
void setTabTitleText(const QString&);
void setRemoteTabTitleText(const QString&);
+ void focusTabTitleText();
+ void focusRemoteTabTitleText();
+
public slots:
void insertTabTitleText(const QString& text);
void insertRemoteTabTitleText(const QString& text);
diff --git a/src/Session.cpp b/src/Session.cpp
index d1834db..d05cbfe 100644
--- a/src/Session.cpp
+++ b/src/Session.cpp
@@ -897,6 +897,14 @@ bool Session::updateForegroundProcessInfo()
return valid;
}
+bool Session::isRemote()
+{
+ ProcessInfo* process = getProcessInfo();
+
+ bool ok = false;
+ return ( process->name(&ok) == "ssh" && ok );
+}
+
QString Session::getDynamicTitle()
{
// update current directory from process
diff --git a/src/Session.h b/src/Session.h
index de78951..def9f92 100644
--- a/src/Session.h
+++ b/src/Session.h
@@ -151,6 +151,13 @@ public:
*/
RemoteTabTitle
};
+
+ /**
+ * Returns true if the session currently contains a connection to a
+ * remote computer. It currently supports ssh.
+ */
+ bool isRemote();
+
/**
* Sets the format used by this session for tab titles.
*
diff --git a/src/SessionController.cpp b/src/SessionController.cpp
index 5f80eb9..ef9fec0 100644
--- a/src/SessionController.cpp
+++ b/src/SessionController.cpp
@@ -550,6 +550,12 @@ void SessionController::renameSession()
dialog->setTabTitleText(_session->tabTitleFormat(Session::LocalTabTitle));
dialog->setRemoteTabTitleText(_session->tabTitleFormat(Session::RemoteTabTitle));
+ if (!_session->isRemote()) {
+ dialog->focusTabTitleText();
+ } else {
+ dialog->focusRemoteTabTitleText();
+ }
+
QPointer<Session> guard(_session);
int result = dialog->exec();
if (!guard)