2101.1.2
by vit9696
Address review comments |
1 |
/*
|
2 |
||
3 |
Copyright 2020 vit9696
|
|
4 |
||
5 |
This file is part of qpdfview.
|
|
6 |
||
7 |
qpdfview is free software: you can redistribute it and/or modify
|
|
8 |
it under the terms of the GNU General Public License as published by
|
|
9 |
the Free Software Foundation, either version 2 of the License, or
|
|
10 |
(at your option) any later version.
|
|
11 |
||
12 |
qpdfview is distributed in the hope that it will be useful,
|
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 |
GNU General Public License for more details.
|
|
16 |
||
17 |
You should have received a copy of the GNU General Public License
|
|
18 |
along with qpdfview. If not, see <http://www.gnu.org/licenses/>.
|
|
19 |
||
20 |
*/
|
|
21 |
||
2102
by Adam Reichold
Merge Vit9696's macOS adjustments, but switch to QPointer to avoid dangling main window pointers. |
22 |
#include <QEvent> |
2101.1.2
by vit9696
Address review comments |
23 |
#include <QFileOpenEvent> |
24 |
||
25 |
#include "application.h" |
|
26 |
#include "mainwindow.h" |
|
27 |
||
28 |
namespace qpdfview { |
|
29 |
||
2102
by Adam Reichold
Merge Vit9696's macOS adjustments, but switch to QPointer to avoid dangling main window pointers. |
30 |
Application::Application(int& argc, char** argv) : QApplication(argc, argv), |
31 |
m_mainWindow() |
|
2101.1.2
by vit9696
Address review comments |
32 |
{
|
33 |
setOrganizationDomain("local.qpdfview"); |
|
34 |
setOrganizationName("qpdfview"); |
|
35 |
setApplicationName("qpdfview"); |
|
36 |
||
37 |
setApplicationVersion(APPLICATION_VERSION); |
|
38 |
||
39 |
#ifdef Q_OS_MAC
|
|
40 |
||
41 |
// On macOS menu icons should not be shown, and app icons are determined by .app bundle.
|
|
42 |
setAttribute(Qt::AA_DontShowIconsInMenus); |
|
43 |
||
44 |
#else
|
|
45 |
||
46 |
setWindowIcon(QIcon(":icons/qpdfview")); |
|
47 |
||
48 |
#endif // Q_OS_MAC |
|
49 |
||
50 |
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
|
51 |
||
52 |
setAttribute(Qt::AA_UseHighDpiPixmaps); |
|
53 |
||
54 |
#endif // QT_VERSION |
|
55 |
}
|
|
56 |
||
2102
by Adam Reichold
Merge Vit9696's macOS adjustments, but switch to QPointer to avoid dangling main window pointers. |
57 |
void Application::setMainWindow(MainWindow* mainWindow) |
2101.1.2
by vit9696
Address review comments |
58 |
{
|
2102
by Adam Reichold
Merge Vit9696's macOS adjustments, but switch to QPointer to avoid dangling main window pointers. |
59 |
m_mainWindow = mainWindow; |
2101.1.2
by vit9696
Address review comments |
60 |
}
|
61 |
||
2102
by Adam Reichold
Merge Vit9696's macOS adjustments, but switch to QPointer to avoid dangling main window pointers. |
62 |
bool Application::event(QEvent* event) |
2101.1.2
by vit9696
Address review comments |
63 |
{
|
2102
by Adam Reichold
Merge Vit9696's macOS adjustments, but switch to QPointer to avoid dangling main window pointers. |
64 |
if(event->type() == QEvent::FileOpen && !m_mainWindow.isNull()) |
2101.1.2
by vit9696
Address review comments |
65 |
{
|
2102
by Adam Reichold
Merge Vit9696's macOS adjustments, but switch to QPointer to avoid dangling main window pointers. |
66 |
QFileOpenEvent* openEvent = static_cast< QFileOpenEvent* >(event); |
67 |
||
68 |
m_mainWindow->jumpToPageOrOpenInNewTab(openEvent->file(), -1, true); |
|
2101.1.2
by vit9696
Address review comments |
69 |
}
|
70 |
||
71 |
return QApplication::event(event); |
|
72 |
}
|
|
73 |
||
74 |
} // qpdfview |