Changeset View
Changeset View
Standalone View
Standalone View
app/mainwindow.cpp
Show All 28 Lines | |||||
29 | #include <QShortcut> | 29 | #include <QShortcut> | ||
30 | #include <QSplitter> | 30 | #include <QSplitter> | ||
31 | #include <QStackedWidget> | 31 | #include <QStackedWidget> | ||
32 | #include <QTimer> | 32 | #include <QTimer> | ||
33 | #include <QUndoGroup> | 33 | #include <QUndoGroup> | ||
34 | #include <QVBoxLayout> | 34 | #include <QVBoxLayout> | ||
35 | #include <QMenuBar> | 35 | #include <QMenuBar> | ||
36 | #include <QUrl> | 36 | #include <QUrl> | ||
37 | #include <QMouseEvent> | ||||
37 | #ifdef Q_OS_OSX | 38 | #ifdef Q_OS_OSX | ||
38 | #include <QFileOpenEvent> | 39 | #include <QFileOpenEvent> | ||
39 | #endif | 40 | #endif | ||
40 | 41 | | |||
41 | // KDE | 42 | // KDE | ||
42 | #include <KActionCategory> | 43 | #include <KActionCategory> | ||
43 | #include <KActionCollection> | 44 | #include <KActionCollection> | ||
44 | #include <QFileDialog> | 45 | #include <QFileDialog> | ||
▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Line(s) | 200 | #endif | |||
273 | } | 274 | } | ||
274 | 275 | | |||
275 | void setupThumbnailView(QWidget* parent) | 276 | void setupThumbnailView(QWidget* parent) | ||
276 | { | 277 | { | ||
277 | Q_ASSERT(mContextManager); | 278 | Q_ASSERT(mContextManager); | ||
278 | mBrowseMainPage = new BrowseMainPage(parent, q->actionCollection(), mGvCore); | 279 | mBrowseMainPage = new BrowseMainPage(parent, q->actionCollection(), mGvCore); | ||
279 | 280 | | |||
280 | mThumbnailView = mBrowseMainPage->thumbnailView(); | 281 | mThumbnailView = mBrowseMainPage->thumbnailView(); | ||
282 | mThumbnailView->viewport()->installEventFilter(q); | ||||
281 | mThumbnailView->setSelectionModel(mContextManager->selectionModel()); | 283 | mThumbnailView->setSelectionModel(mContextManager->selectionModel()); | ||
282 | mUrlNavigator = mBrowseMainPage->urlNavigator(); | 284 | mUrlNavigator = mBrowseMainPage->urlNavigator(); | ||
283 | 285 | | |||
284 | mDocumentInfoProvider = new DocumentInfoProvider(mDirModel); | 286 | mDocumentInfoProvider = new DocumentInfoProvider(mDirModel); | ||
285 | mThumbnailView->setDocumentInfoProvider(mDocumentInfoProvider); | 287 | mThumbnailView->setDocumentInfoProvider(mDocumentInfoProvider); | ||
286 | 288 | | |||
287 | mThumbnailViewHelper = new ThumbnailViewHelper(mDirModel, q->actionCollection()); | 289 | mThumbnailViewHelper = new ThumbnailViewHelper(mDirModel, q->actionCollection()); | ||
288 | connect(mContextManager, &ContextManager::currentDirUrlChanged, | 290 | connect(mContextManager, &ContextManager::currentDirUrlChanged, | ||
▲ Show 20 Lines • Show All 676 Lines • ▼ Show 20 Line(s) | 965 | if (action == d->mViewAction) { | |||
965 | // Switching to view mode | 967 | // Switching to view mode | ||
966 | d->mViewStackedWidget->setCurrentWidget(d->mViewMainPage); | 968 | d->mViewStackedWidget->setCurrentWidget(d->mViewMainPage); | ||
967 | openSelectedDocuments(); | 969 | openSelectedDocuments(); | ||
968 | d->mPreloadDirectionIsForward = true; | 970 | d->mPreloadDirectionIsForward = true; | ||
969 | QTimer::singleShot(VIEW_PRELOAD_DELAY, this, &MainWindow::preloadNextUrl); | 971 | QTimer::singleShot(VIEW_PRELOAD_DELAY, this, &MainWindow::preloadNextUrl); | ||
970 | } else { | 972 | } else { | ||
971 | d->mCurrentMainPageId = BrowseMainPageId; | 973 | d->mCurrentMainPageId = BrowseMainPageId; | ||
972 | // Switching to browse mode | 974 | // Switching to browse mode | ||
973 | d->mViewStackedWidget->setCurrentWidget(d->mBrowseMainPage); | 975 | d->mViewStackedWidget->setCurrentWidget(d->mBrowseMainPage); | ||
rkflx: Unrelated whitespace change, please revert. | |||||
974 | if (!d->mViewMainPage->isEmpty() | 976 | if (!d->mViewMainPage->isEmpty() | ||
975 | && KProtocolManager::supportsListing(d->mViewMainPage->url())) { | 977 | && KProtocolManager::supportsListing(d->mViewMainPage->url())) { | ||
976 | // Reset the view to spare resources, but don't do it if we can't | 978 | // Reset the view to spare resources, but don't do it if we can't | ||
977 | // browse the url, otherwise if the user starts Gwenview this way: | 979 | // browse the url, otherwise if the user starts Gwenview this way: | ||
978 | // gwenview http://example.com/example.png | 980 | // gwenview http://example.com/example.png | ||
979 | // and switch to browse mode, switching back to view mode won't bring | 981 | // and switch to browse mode, switching back to view mode won't bring | ||
980 | // his image back. | 982 | // his image back. | ||
981 | d->mViewMainPage->reset(); | 983 | d->mViewMainPage->reset(); | ||
▲ Show 20 Lines • Show All 519 Lines • ▼ Show 20 Line(s) | 1484 | { | |||
1501 | switch (answer) { | 1503 | switch (answer) { | ||
1502 | case KMessageBox::Yes: | 1504 | case KMessageBox::Yes: | ||
1503 | d->mGvCore->saveAll(); | 1505 | d->mGvCore->saveAll(); | ||
1504 | // We need to wait a bit because the DocumentFactory is notified about | 1506 | // We need to wait a bit because the DocumentFactory is notified about | ||
1505 | // saved documents through a queued connection. | 1507 | // saved documents through a queued connection. | ||
1506 | qApp->processEvents(); | 1508 | qApp->processEvents(); | ||
1507 | return DocumentFactory::instance()->modifiedDocumentList().isEmpty(); | 1509 | return DocumentFactory::instance()->modifiedDocumentList().isEmpty(); | ||
1508 | 1510 | | |||
1509 | case KMessageBox::No: | 1511 | case KMessageBox::No: | ||
rkflx: Unrelated whitespace change, please revert. | |||||
1510 | return true; | 1512 | return true; | ||
1511 | 1513 | | |||
1512 | default: // cancel | 1514 | default: // cancel | ||
1513 | return false; | 1515 | return false; | ||
1514 | } | 1516 | } | ||
1515 | } | 1517 | } | ||
1516 | 1518 | | |||
1517 | void MainWindow::showConfigDialog() | 1519 | void MainWindow::showConfigDialog() | ||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Line(s) | 1664 | #ifdef Q_OS_OSX | |||
1664 | * handle Mac OS X file open events (only exist on OS X) | 1666 | * handle Mac OS X file open events (only exist on OS X) | ||
1665 | */ | 1667 | */ | ||
1666 | if (event->type() == QEvent::FileOpen) { | 1668 | if (event->type() == QEvent::FileOpen) { | ||
1667 | QFileOpenEvent *fileOpenEvent = static_cast<QFileOpenEvent*>(event); | 1669 | QFileOpenEvent *fileOpenEvent = static_cast<QFileOpenEvent*>(event); | ||
1668 | openUrl(fileOpenEvent->url()); | 1670 | openUrl(fileOpenEvent->url()); | ||
1669 | return true; | 1671 | return true; | ||
1670 | } | 1672 | } | ||
1671 | #endif | 1673 | #endif | ||
1674 | if (obj == d->mThumbnailView->viewport()) { | ||||
1675 | switch(event->type()) { | ||||
1676 | case QEvent::MouseButtonPress: | ||||
1677 | case QEvent::MouseButtonDblClick: | ||||
1678 | mouseButtonNavigate(static_cast<QMouseEvent*>(event)); | ||||
1679 | break; | ||||
1680 | default: ; | ||||
1681 | } | ||||
1682 | } | ||||
1672 | return false; | 1683 | return false; | ||
1673 | } | 1684 | } | ||
1674 | 1685 | | |||
1686 | void MainWindow::mousePressEvent(QMouseEvent *event) | ||||
1687 | { | ||||
1688 | mouseButtonNavigate(event); | ||||
1689 | KXmlGuiWindow::mousePressEvent(event); | ||||
1690 | } | ||||
1691 | | ||||
1692 | void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) | ||||
1693 | { | ||||
1694 | mouseButtonNavigate(event); | ||||
1695 | KXmlGuiWindow::mouseDoubleClickEvent(event); | ||||
1696 | } | ||||
1697 | | ||||
1698 | void MainWindow::mouseButtonNavigate(QMouseEvent *event) | ||||
1699 | { | ||||
1700 | switch(event->button()) { | ||||
1701 | case Qt::ForwardButton: | ||||
1702 | if (d->mGoToNextAction->isEnabled()) { | ||||
1703 | d->mGoToNextAction->trigger(); | ||||
1704 | return; | ||||
1705 | } | ||||
1706 | break; | ||||
1707 | case Qt::BackButton: | ||||
1708 | if (d->mGoToPreviousAction->isEnabled()) { | ||||
1709 | d->mGoToPreviousAction->trigger(); | ||||
1710 | return; | ||||
1711 | } | ||||
1712 | break; | ||||
1713 | default: ; | ||||
1714 | } | ||||
1715 | } | ||||
1716 | | ||||
1675 | void MainWindow::setDistractionFreeMode(bool value) | 1717 | void MainWindow::setDistractionFreeMode(bool value) | ||
1676 | { | 1718 | { | ||
1677 | d->mFullScreenContent->setDistractionFreeMode(value); | 1719 | d->mFullScreenContent->setDistractionFreeMode(value); | ||
1678 | } | 1720 | } | ||
1679 | 1721 | | |||
1680 | void MainWindow::saveProperties(KConfigGroup& group) | 1722 | void MainWindow::saveProperties(KConfigGroup& group) | ||
1681 | { | 1723 | { | ||
1682 | group.writeEntry(SESSION_CURRENT_PAGE_KEY, int(d->mCurrentMainPageId)); | 1724 | group.writeEntry(SESSION_CURRENT_PAGE_KEY, int(d->mCurrentMainPageId)); | ||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |
Unrelated whitespace change, please revert.