~ubuntu-branches/ubuntu/trusty/yakuake/trusty

« back to all changes in this revision

Viewing changes to app/tabbar.cpp

  • Committer: Package Import Robot
  • Author(s): Ana Beatriz Guerrero Lopez
  • Date: 2013-07-15 00:14:52 UTC
  • mfrom: (0.1.13)
  • Revision ID: package-import@ubuntu.com-20130715001452-v3p5w7tjds235znn
Tags: 2.9.9-1
* New upstream release:
 - Fixes: Yakuake does not show shell tabs when opening on a smaller screen
   using TwinView. (Closes: #523526)
* Update minimum dependencies to KDE >= 4.7.1
* Update to Standards-Version 3.9.4, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "skin.h"
26
26
#include "session.h"
27
27
#include "sessionstack.h"
 
28
#include "settings.h"
28
29
 
29
30
#include <KLineEdit>
30
31
#include <KMenu>
31
32
#include <KPushButton>
 
33
#include <KActionCollection>
 
34
#include <KGlobalSettings>
 
35
#include <KLocalizedString>
32
36
 
33
37
#include <QBitmap>
34
38
#include <QPainter>
35
39
#include <QtDBus/QtDBus>
36
40
#include <QToolButton>
37
41
#include <QWheelEvent>
 
42
#include <QWhatsThis>
38
43
 
39
44
#include <QMimeData>
40
45
#include <QDrag>
66
71
    connect(m_tabContextMenu, SIGNAL(hovered(QAction*)), this, SLOT(contextMenuActionHovered(QAction*)));
67
72
 
68
73
    m_toggleKeyboardInputMenu = new KMenu(i18nc("@title:menu", "Disable Keyboard Input"), this);
 
74
    m_toggleMonitorActivityMenu = new KMenu(i18nc("@title:menu", "Monitor for Activity"), this);
 
75
    m_toggleMonitorSilenceMenu = new KMenu(i18nc("@title:menu", "Monitor for Silence"), this);
69
76
 
70
77
    m_sessionMenu = new KMenu(this);
71
78
    connect(m_sessionMenu, SIGNAL(aboutToShow()), this, SLOT(readySessionMenu()));
122
129
        m_tabContextMenu->addSeparator();
123
130
        m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("edit-profile"));
124
131
        m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("rename-session"));
 
132
        m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("toggle-session-prevent-closing"));
125
133
        m_tabContextMenu->addMenu(m_toggleKeyboardInputMenu);
126
 
        m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("toggle-session-prevent-closing"));
 
134
        m_tabContextMenu->addMenu(m_toggleMonitorActivityMenu);
 
135
        m_tabContextMenu->addMenu(m_toggleMonitorSilenceMenu);
127
136
        m_tabContextMenu->addSeparator();
128
137
        m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("move-session-left"));
129
138
        m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("move-session-right"));
166
175
    KActionCollection* actionCollection = m_mainWindow->actionCollection();
167
176
    SessionStack* sessionStack = m_mainWindow->sessionStack();
168
177
 
169
 
    QAction* toggleAction = actionCollection->action("toggle-session-keyboard-input");
170
 
    toggleAction->setChecked(!sessionStack->isSessionKeyboardInputEnabled(sessionId));
171
 
 
172
 
    toggleAction = actionCollection->action("toggle-session-prevent-closing");
 
178
    QAction* toggleAction = actionCollection->action("toggle-session-prevent-closing");
173
179
    toggleAction->setChecked(!sessionStack->isSessionClosable(sessionId));
 
180
 
 
181
    toggleAction = actionCollection->action("toggle-session-keyboard-input");
 
182
    toggleAction->setChecked(!sessionStack->hasTerminalsWithKeyboardInputEnabled(sessionId));
 
183
 
 
184
    toggleAction = actionCollection->action("toggle-session-monitor-activity");
 
185
    toggleAction->setChecked(!sessionStack->hasTerminalsWithMonitorActivityDisabled(sessionId));
 
186
 
 
187
    toggleAction = actionCollection->action("toggle-session-monitor-silence");
 
188
    toggleAction->setChecked(!sessionStack->hasTerminalsWithMonitorSilenceDisabled(sessionId));
174
189
}
175
190
 
176
191
void TabBar::updateToggleKeyboardInputMenu(int sessionId)
221
236
    }
222
237
}
223
238
 
 
239
void TabBar::updateToggleMonitorActivityMenu(int sessionId)
 
240
{
 
241
    if (!m_tabs.contains(sessionId)) return;
 
242
 
 
243
    QAction* toggleMonitorActivityAction = m_mainWindow->actionCollection()->action("toggle-session-monitor-activity");
 
244
    QAction* anchor = m_toggleMonitorActivityMenu->menuAction();
 
245
 
 
246
    SessionStack* sessionStack = m_mainWindow->sessionStack();
 
247
 
 
248
    QStringList terminalIds = sessionStack->terminalIdsForSessionId(sessionId).split(',', QString::SkipEmptyParts);
 
249
 
 
250
    m_toggleMonitorActivityMenu->clear();
 
251
 
 
252
    if (terminalIds.count() <= 1)
 
253
    {
 
254
        toggleMonitorActivityAction->setText(i18nc("@action", "Monitor for Activity"));
 
255
        m_tabContextMenu->insertAction(anchor, toggleMonitorActivityAction);
 
256
        m_toggleMonitorActivityMenu->menuAction()->setVisible(false);
 
257
    }
 
258
    else
 
259
    {
 
260
        toggleMonitorActivityAction->setText(i18nc("@action", "In This Session"));
 
261
        m_toggleMonitorActivityMenu->menuAction()->setVisible(true);
 
262
 
 
263
        m_tabContextMenu->removeAction(toggleMonitorActivityAction);
 
264
        m_toggleMonitorActivityMenu->addAction(toggleMonitorActivityAction);
 
265
 
 
266
        m_toggleMonitorActivityMenu->addSeparator();
 
267
 
 
268
        int count = 0;
 
269
 
 
270
        QStringListIterator i(terminalIds);
 
271
 
 
272
        while (i.hasNext())
 
273
        {
 
274
            int terminalId = i.next().toInt();
 
275
 
 
276
            ++count;
 
277
 
 
278
            QAction* action = m_toggleMonitorActivityMenu->addAction(i18nc("@action", "In Terminal %1", count));
 
279
            action->setCheckable(true);
 
280
            action->setChecked(sessionStack->isTerminalMonitorActivityEnabled(terminalId));
 
281
            action->setData(terminalId);
 
282
            connect(action, SIGNAL(triggered(bool)), m_mainWindow, SLOT(handleToggleTerminalMonitorActivity(bool)));
 
283
        }
 
284
    }
 
285
}
 
286
 
 
287
void TabBar::updateToggleMonitorSilenceMenu(int sessionId)
 
288
{
 
289
    if (!m_tabs.contains(sessionId)) return;
 
290
 
 
291
    QAction* toggleMonitorSilenceAction = m_mainWindow->actionCollection()->action("toggle-session-monitor-silence");
 
292
    QAction* anchor = m_toggleMonitorSilenceMenu->menuAction();
 
293
 
 
294
    SessionStack* sessionStack = m_mainWindow->sessionStack();
 
295
 
 
296
    QStringList terminalIds = sessionStack->terminalIdsForSessionId(sessionId).split(',', QString::SkipEmptyParts);
 
297
 
 
298
    m_toggleMonitorSilenceMenu->clear();
 
299
 
 
300
    if (terminalIds.count() <= 1)
 
301
    {
 
302
        toggleMonitorSilenceAction->setText(i18nc("@action", "Monitor for Silence"));
 
303
        m_tabContextMenu->insertAction(anchor, toggleMonitorSilenceAction);
 
304
        m_toggleMonitorSilenceMenu->menuAction()->setVisible(false);
 
305
    }
 
306
    else
 
307
    {
 
308
        toggleMonitorSilenceAction->setText(i18nc("@action", "In This Session"));
 
309
        m_toggleMonitorSilenceMenu->menuAction()->setVisible(true);
 
310
 
 
311
        m_tabContextMenu->removeAction(toggleMonitorSilenceAction);
 
312
        m_toggleMonitorSilenceMenu->addAction(toggleMonitorSilenceAction);
 
313
 
 
314
        m_toggleMonitorSilenceMenu->addSeparator();
 
315
 
 
316
        int count = 0;
 
317
 
 
318
        QStringListIterator i(terminalIds);
 
319
 
 
320
        while (i.hasNext())
 
321
        {
 
322
            int terminalId = i.next().toInt();
 
323
 
 
324
            ++count;
 
325
 
 
326
            QAction* action = m_toggleMonitorSilenceMenu->addAction(i18nc("@action", "In Terminal %1", count));
 
327
            action->setCheckable(true);
 
328
            action->setChecked(sessionStack->isTerminalMonitorSilenceEnabled(terminalId));
 
329
            action->setData(terminalId);
 
330
            connect(action, SIGNAL(triggered(bool)), m_mainWindow, SLOT(handleToggleTerminalMonitorSilence(bool)));
 
331
        }
 
332
    }
 
333
}
 
334
 
224
335
void TabBar::contextMenuActionHovered(QAction* action)
225
336
{
226
337
    bool ok = false;
252
363
        int sessionId = sessionAtTab(index);
253
364
        updateToggleActions(sessionId);
254
365
        updateToggleKeyboardInputMenu(sessionId);
 
366
        updateToggleMonitorActivityMenu(sessionId);
 
367
        updateToggleMonitorSilenceMenu(sessionId);
255
368
 
256
369
        m_mainWindow->setContextDependentActionsQuiet(true);
257
370
 
272
385
        updateMoveActions(m_tabs.indexOf(m_selectedSessionId));
273
386
        updateToggleActions(m_selectedSessionId);
274
387
        updateToggleKeyboardInputMenu(m_selectedSessionId);
 
388
        updateToggleMonitorActivityMenu(m_selectedSessionId);
 
389
        updateToggleMonitorSilenceMenu(m_selectedSessionId);
275
390
    }
276
391
 
277
392
    QWidget::contextMenuEvent(event);
369
484
        if (selected)
370
485
            painter.drawTiledPixmap(x, y,
371
486
                    m_skin->tabBarPreventClosingImagePosition().x() +
372
 
                    m_skin->tabBarPreventClosingImage().width(), height(), 
 
487
                    m_skin->tabBarPreventClosingImage().width(), height(),
373
488
                    m_skin->tabBarSelectedBackgroundImage());
374
489
        else
375
 
            painter.drawTiledPixmap(x, y, 
 
490
            painter.drawTiledPixmap(x, y,
376
491
                    m_skin->tabBarPreventClosingImagePosition().x() +
377
492
                    m_skin->tabBarPreventClosingImage().width(), height(),
378
493
                    m_skin->tabBarUnselectedBackgroundImage());
640
755
    m_tabTitles.remove(sessionId);
641
756
 
642
757
    if (m_tabs.count() == 0)
643
 
        emit newTabRequested();
 
758
        emit lastTabClosed();
644
759
    else
645
760
        emit tabSelected(m_tabs.last());
646
761
}