source: terepaima/terepaima-0.4.16/sources/recentlyclosedmenu.cpp

desarrollostretch
Last change on this file was 1f4adec, checked in by aosorio <aosorio@…>, 8 years ago

Agregado proyecto base, esto luego del dh_make -f

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2
3Copyright 2013 Adam Reichold
4
5This file is part of qpdfview.
6
7qpdfview is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 2 of the License, or
10(at your option) any later version.
11
12qpdfview is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with qpdfview.  If not, see <http://www.gnu.org/licenses/>.
19
20*/
21
22#include "recentlyclosedmenu.h"
23
24#include "documentview.h"
25
26namespace qpdfview
27{
28
29RecentlyClosedMenu::RecentlyClosedMenu(int count, QWidget* parent) : QMenu(parent),
30    m_count(count)
31{
32    menuAction()->setText(tr("&Recently closed"));
33
34    m_tabActionGroup = new QActionGroup(this);
35    connect(m_tabActionGroup, SIGNAL(triggered(QAction*)), SLOT(on_tabAction_triggered(QAction*)));
36
37    m_separatorAction = addSeparator();
38
39    m_clearListAction = addAction(tr("&Clear list"));
40    connect(m_clearListAction, SIGNAL(triggered()), SLOT(on_clearList_triggered()));
41}
42
43void RecentlyClosedMenu::addTabAction(QAction* tabAction)
44{
45    if(m_tabActionGroup->actions().count() >= m_count)
46    {
47        QAction* first = m_tabActionGroup->actions().first();
48
49        removeAction(first);
50        m_tabActionGroup->removeAction(first);
51
52        first->parent()->deleteLater();
53    }
54
55    insertAction(actions().first(), tabAction);
56    m_tabActionGroup->addAction(tabAction);
57}
58
59void RecentlyClosedMenu::triggerFirstTabAction()
60{
61    const QList< QAction* >& actions = m_tabActionGroup->actions();
62
63    if(!actions.isEmpty())
64    {
65        on_tabAction_triggered(actions.first());
66    }
67}
68
69void RecentlyClosedMenu::triggerLastTabAction()
70{
71    const QList< QAction* >& actions = m_tabActionGroup->actions();
72
73    if(!actions.isEmpty())
74    {
75        on_tabAction_triggered(actions.last());
76    }
77}
78
79void RecentlyClosedMenu::on_tabAction_triggered(QAction* tabAction)
80{
81    removeAction(tabAction);
82    m_tabActionGroup->removeAction(tabAction);
83
84    emit tabActionTriggered(tabAction);
85}
86
87void RecentlyClosedMenu::on_clearList_triggered()
88{
89    foreach(QAction* action, m_tabActionGroup->actions())
90    {
91        action->parent()->deleteLater();
92    }
93}
94
95} // qpdfview
Note: See TracBrowser for help on using the repository browser.