[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/utils/yakuake
From:       Eike Hein <hein () kde ! org>
Date:       2009-03-19 17:50:30
Message-ID: 1237485030.696393.3396.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 941471 by hein:

Add a feature to disable keyboard input for a session (via
shortcut or the context menu).
Also adds the necessary scaffolding to handle context-depen-
dent toggle acctions.
CCMAIL:carlosdgtorres@gmail.com


 M  +2 -0      ChangeLog  
 M  +18 -0     app/mainwindow.cpp  
 M  +1 -0      app/mainwindow.h  
 M  +18 -0     app/session.cpp  
 M  +5 -0      app/session.h  
 M  +9 -0      app/sessionstack.cpp  
 M  +2 -0      app/sessionstack.h  
 M  +9 -1      app/tabbar.cpp  
 M  +13 -0     app/terminal.cpp  
 M  +5 -0      app/terminal.h  


--- trunk/extragear/utils/yakuake/ChangeLog #941470:941471
@@ -12,6 +12,8 @@
   and 'terminalIdsForSessionId(int sessionId)' D-Bus interfaces.
 * Rewrote the translucency support not to use X11-specific code on Qt 4.5
   or higher and KDE 4.3 or higher.
+* Added a feature to disable keyboard input for a session (via a user-con-
+  figured shortcut or the context menu).
 
 
 Changes in 2.9.4:
--- trunk/extragear/utils/yakuake/app/mainwindow.cpp #941470:941471
@@ -289,6 +289,13 @@
     connect(action, SIGNAL(triggered()), this, \
SLOT(handleContextDependentAction()));  m_contextDependentActions << action;
 
+    action = actionCollection()->addAction("toggle-keyboard-input");
+    action->setText(i18nc("@action", "Disable Keyboard Input"));
+    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_U));
+    action->setCheckable(true);
+    connect(action, SIGNAL(toggled(bool)), this, \
SLOT(handleContextDependentToggleAction(bool))); +    m_contextDependentActions << \
action; +
     for (uint i = 1; i <= 10; ++i)
     {
         action = actionCollection()->addAction(QString("switch-to-session-%1").arg(i));
 @@ -333,6 +340,17 @@
         m_sessionStack->splitTopBottom(sessionId);
 }
 
+void MainWindow::handleContextDependentToggleAction(bool toggle, QAction* action, \
int sessionId) +{
+    if (sessionId == -1) sessionId = m_sessionStack->activeSessionId();
+    if (sessionId == -1) return;
+
+    if (!action) action = qobject_cast<QAction*>(QObject::sender());
+
+    if (action == actionCollection()->action("toggle-keyboard-input"))
+        m_sessionStack->setKeyboardInputEnabled(sessionId, !toggle);
+}
+
 void MainWindow::setContextDependentActionsQuiet(bool quiet)
 {
     for (int i = 0; i < m_contextDependentActions.size(); ++i)
--- trunk/extragear/utils/yakuake/app/mainwindow.h #941470:941471
@@ -69,6 +69,7 @@
         Q_SCRIPTABLE void toggleWindowState();
 
         void handleContextDependentAction(QAction* action = 0, int sessionId = -1);
+        void handleContextDependentToggleAction(bool toggle, QAction* action = 0, \
int sessionId = -1);  
 
     protected:
--- trunk/extragear/utils/yakuake/app/session.cpp #941470:941471
@@ -32,6 +32,8 @@
 
     m_activeTerminalId = -1;
 
+    m_keyboardInputEnabled = true;
+
     m_baseSplitter = new Splitter(Qt::Horizontal, parent);
     connect(m_baseSplitter, SIGNAL(destroyed()), this, SLOT(prepareShutdown()));
 
@@ -145,6 +147,8 @@
 
     m_terminals.insert(terminal->id(), terminal);
 
+    terminal->setKeyboardInputEnabled(m_keyboardInputEnabled);
+
     QWidget* terminalWidget = terminal->terminalWidget();
     if (terminalWidget) terminalWidget->setFocus();
 
@@ -384,3 +388,17 @@
 
     m_terminals[m_activeTerminalId]->editProfile();
 }
+
+void Session::setKeyboardInputEnabled(bool keyboardInputEnabled)
+{
+    m_keyboardInputEnabled = keyboardInputEnabled;
+
+    QMapIterator<int, Terminal*> it(m_terminals);
+
+    while (it.hasNext())
+    {
+        it.next();
+
+        it.value()->setKeyboardInputEnabled(m_keyboardInputEnabled);
+    }
+}
--- trunk/extragear/utils/yakuake/app/session.h #941470:941471
@@ -65,7 +65,10 @@
         void manageProfiles();
         void editProfile();
 
+        bool keyboardInputEnabled() { return m_keyboardInputEnabled; }
+        void setKeyboardInputEnabled(bool keyboardInputEnabled);
 
+
     signals:
         void titleChanged(const QString& title);
         void titleChanged(int sessionId, const QString& title);
@@ -96,6 +99,8 @@
         QMap<int, Terminal*> m_terminals;
 
         QString m_title;
+
+        bool m_keyboardInputEnabled;
 };
 
 #endif 
--- trunk/extragear/utils/yakuake/app/sessionstack.cpp #941470:941471
@@ -231,6 +231,15 @@
     }
 }
 
+void SessionStack::setKeyboardInputEnabled(int sessionId, bool keyboardInputEnabled)
+{
+    if (sessionId == -1) sessionId = m_activeSessionId;
+    if (sessionId == -1) return;
+    if (!m_sessions.contains(sessionId)) return;
+
+    m_sessions[sessionId]->setKeyboardInputEnabled(keyboardInputEnabled);
+}
+
 void SessionStack::editProfile(int sessionId)
 {
     if (sessionId == -1) sessionId = m_activeSessionId;
--- trunk/extragear/utils/yakuake/app/sessionstack.h #941470:941471
@@ -73,7 +73,9 @@
         Q_SCRIPTABLE void runCommand(const QString& command);
         Q_SCRIPTABLE void runCommandInTerminal(int terminalId, const QString& \
command);  
+        Q_SCRIPTABLE void setKeyboardInputEnabled(int sessionId, bool \
keyboardInputEnabled);  
+
     signals:
         void sessionAdded(int sessionId, const QString& title = 0);
         void sessionRaised(int sessionId);
--- trunk/extragear/utils/yakuake/app/tabbar.cpp #941470:941471
@@ -114,6 +114,8 @@
         m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("edit-profile"));
                
         m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("close-active-terminal"));
  m_tabContextMenu->addSeparator();
+        m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("toggle-keyboard-input"));
 +        m_tabContextMenu->addSeparator();
         m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("move-session-left"));
                
         m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("move-session-right"));
  m_tabContextMenu->addSeparator();
@@ -164,7 +166,13 @@
 
         QAction* action = m_tabContextMenu->exec(QCursor::pos());
 
-        if (action) m_mainWindow->handleContextDependentAction(action, \
sessionAtTab(index)); +        if (action)
+        {
+            if (action->isCheckable())
+                m_mainWindow->handleContextDependentToggleAction(action->isChecked(), \
action, sessionAtTab(index)); +            else
+                m_mainWindow->handleContextDependentAction(action, \
sessionAtTab(index)); +        }
 
         m_mainWindow->setContextDependentActionsQuiet(false);
 
--- trunk/extragear/utils/yakuake/app/terminal.cpp #941470:941471
@@ -45,6 +45,8 @@
     m_terminalId = m_availableTerminalId;
     m_availableTerminalId++;
 
+    m_keyboardInputEnabled = true;
+
     m_part = NULL;
     m_terminalInterface = NULL;
     m_partWidget = NULL;
@@ -102,6 +104,12 @@
             m_terminalWidget->setFocus();
     }
 
+    if (!m_keyboardInputEnabled)
+    {
+        if (event->type() == QEvent::KeyPress || event->type() == \
QEvent::KeyRelease) +            return true;
+    }
+
     return false;
 }
 
@@ -204,6 +212,11 @@
         Qt::QueuedConnection, Q_ARG(QWidget*, KApplication::activeWindow()));
 }
 
+void Terminal::setKeyboardInputEnabled(bool keyboardInputEnabled)
+{
+    m_keyboardInputEnabled = keyboardInputEnabled;
+}
+
 void Terminal::overrideShortcut(QKeyEvent* /* event */, bool& override)
 {
     override = false;
--- trunk/extragear/utils/yakuake/app/terminal.h #941470:941471
@@ -55,6 +55,9 @@
         void manageProfiles();
         void editProfile();
 
+        bool keyboardInputEnabled() { return m_keyboardInputEnabled; }
+        void setKeyboardInputEnabled(bool keyboardInputEnabled);
+
         void deletePart();
 
 
@@ -84,6 +87,8 @@
         QWidget* m_parentSplitter;
 
         QString m_title;
+
+        bool m_keyboardInputEnabled;
 };
 
 #endif 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic