source: terepaima/terepaima-0.4.16/sources/bookmarkmenu.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: 3.3 KB
Line 
1/*
2
3Copyright 2014 S. Razi Alavizadeh
4Copyright 2012-2014 Adam Reichold
5
6This file is part of qpdfview.
7
8qpdfview is free software: you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 2 of the License, or
11(at your option) any later version.
12
13qpdfview is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with qpdfview.  If not, see <http://www.gnu.org/licenses/>.
20
21*/
22
23#include "bookmarkmenu.h"
24
25#include "miscellaneous.h"
26
27#include <QFileInfo>
28
29namespace qpdfview
30{
31
32BookmarkMenu::BookmarkMenu(const QFileInfo& fileInfo, QWidget* parent) : QMenu(parent)
33{
34    menuAction()->setText(fileInfo.completeBaseName());
35    menuAction()->setToolTip(fileInfo.absoluteFilePath());
36
37    menuAction()->setData(fileInfo.absoluteFilePath());
38
39    m_openAction = addAction(tr("&Open"));
40    m_openAction->setIcon(loadIconWithFallback(QLatin1String("document-open")));
41    m_openAction->setIconVisibleInMenu(true);
42    connect(m_openAction, SIGNAL(triggered()), SLOT(on_open_triggered()));
43
44    m_openInNewTabAction = addAction(tr("Open in new &tab"));
45    m_openInNewTabAction->setIcon(loadIconWithFallback(QLatin1String("tab-new")));
46    m_openInNewTabAction->setIconVisibleInMenu(true);
47    connect(m_openInNewTabAction, SIGNAL(triggered()), SLOT(on_openInNewTab_triggered()));
48
49    m_jumpToPageActionGroup = new QActionGroup(this);
50    connect(m_jumpToPageActionGroup, SIGNAL(triggered(QAction*)), SLOT(on_jumpToPage_triggered(QAction*)));
51
52    m_separatorAction = addSeparator();
53
54    m_removeBookmarkAction = addAction(tr("&Remove bookmark"));
55    connect(m_removeBookmarkAction, SIGNAL(triggered()), SLOT(on_removeBookmark_triggered()));
56}
57
58void BookmarkMenu::addJumpToPageAction(int page, const QString& label)
59{
60    QAction* before = m_separatorAction;
61
62    foreach(QAction* action, m_jumpToPageActionGroup->actions())
63    {
64        if(action->data().toInt() == page)
65        {
66            action->setText(label);
67
68            return;
69        }
70        else if(action->data().toInt() > page)
71        {
72            before = action;
73
74            break;
75        }
76    }
77
78    QAction* action = new QAction(label, this);
79    action->setIcon(loadIconWithFallback(QLatin1String("go-jump")));
80    action->setIconVisibleInMenu(true);
81    action->setData(page);
82
83    insertAction(before, action);
84    m_jumpToPageActionGroup->addAction(action);
85}
86
87void BookmarkMenu::removeJumpToPageAction(int page)
88{
89    foreach(QAction* action, m_jumpToPageActionGroup->actions())
90    {
91        if(action->data().toInt() == page)
92        {
93            delete action;
94
95            break;
96        }
97    }
98}
99
100void BookmarkMenu::on_open_triggered()
101{
102    emit openTriggered(absoluteFilePath());
103}
104
105void BookmarkMenu::on_openInNewTab_triggered()
106{
107    emit openInNewTabTriggered(absoluteFilePath());
108}
109
110void BookmarkMenu::on_jumpToPage_triggered(QAction* action)
111{
112    emit jumpToPageTriggered(absoluteFilePath(), action->data().toInt());
113}
114
115void BookmarkMenu::on_removeBookmark_triggered()
116{
117    emit removeBookmarkTriggered(absoluteFilePath());
118}
119
120} // qpdfview
Note: See TracBrowser for help on using the repository browser.