Changeset View
Changeset View
Standalone View
Standalone View
app/mainwindow.cpp
Show All 27 Lines | |||||
28 | #include <QShortcut> | 28 | #include <QShortcut> | ||
29 | #include <QSplitter> | 29 | #include <QSplitter> | ||
30 | #include <QStackedWidget> | 30 | #include <QStackedWidget> | ||
31 | #include <QTimer> | 31 | #include <QTimer> | ||
32 | #include <QUndoGroup> | 32 | #include <QUndoGroup> | ||
33 | #include <QVBoxLayout> | 33 | #include <QVBoxLayout> | ||
34 | #include <QMenuBar> | 34 | #include <QMenuBar> | ||
35 | #include <QUrl> | 35 | #include <QUrl> | ||
36 | #include <QMouseEvent> | ||||
36 | #ifdef Q_OS_OSX | 37 | #ifdef Q_OS_OSX | ||
37 | #include <QFileOpenEvent> | 38 | #include <QFileOpenEvent> | ||
38 | #endif | 39 | #endif | ||
39 | 40 | | |||
40 | // KDE | 41 | // KDE | ||
41 | #include <KActionCategory> | 42 | #include <KActionCategory> | ||
42 | #include <KActionCollection> | 43 | #include <KActionCollection> | ||
43 | #include <QFileDialog> | 44 | #include <QFileDialog> | ||
▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Line(s) | 198 | #endif | |||
271 | } | 272 | } | ||
272 | 273 | | |||
273 | void setupThumbnailView(QWidget* parent) | 274 | void setupThumbnailView(QWidget* parent) | ||
274 | { | 275 | { | ||
275 | Q_ASSERT(mContextManager); | 276 | Q_ASSERT(mContextManager); | ||
276 | mBrowseMainPage = new BrowseMainPage(parent, q->actionCollection(), mGvCore); | 277 | mBrowseMainPage = new BrowseMainPage(parent, q->actionCollection(), mGvCore); | ||
277 | 278 | | |||
278 | mThumbnailView = mBrowseMainPage->thumbnailView(); | 279 | mThumbnailView = mBrowseMainPage->thumbnailView(); | ||
280 | mThumbnailView->viewport()->installEventFilter(q); | ||||
279 | mThumbnailView->setSelectionModel(mContextManager->selectionModel()); | 281 | mThumbnailView->setSelectionModel(mContextManager->selectionModel()); | ||
280 | mUrlNavigator = mBrowseMainPage->urlNavigator(); | 282 | mUrlNavigator = mBrowseMainPage->urlNavigator(); | ||
281 | 283 | | |||
282 | mDocumentInfoProvider = new DocumentInfoProvider(mDirModel); | 284 | mDocumentInfoProvider = new DocumentInfoProvider(mDirModel); | ||
283 | mThumbnailView->setDocumentInfoProvider(mDocumentInfoProvider); | 285 | mThumbnailView->setDocumentInfoProvider(mDocumentInfoProvider); | ||
284 | 286 | | |||
285 | mThumbnailViewHelper = new ThumbnailViewHelper(mDirModel, q->actionCollection()); | 287 | mThumbnailViewHelper = new ThumbnailViewHelper(mDirModel, q->actionCollection()); | ||
286 | connect(mContextManager, SIGNAL(currentDirUrlChanged(QUrl)), | 288 | connect(mContextManager, SIGNAL(currentDirUrlChanged(QUrl)), | ||
▲ Show 20 Lines • Show All 678 Lines • ▼ Show 20 Line(s) | 963 | if (!d->mViewMainPage->isEmpty() | |||
965 | // gwenview http://example.com/example.png | 967 | // gwenview http://example.com/example.png | ||
966 | // and switch to browse mode, switching back to view mode won't bring | 968 | // and switch to browse mode, switching back to view mode won't bring | ||
967 | // his image back. | 969 | // his image back. | ||
968 | d->mViewMainPage->reset(); | 970 | d->mViewMainPage->reset(); | ||
969 | } | 971 | } | ||
970 | setCaption(QString()); | 972 | setCaption(QString()); | ||
971 | } | 973 | } | ||
972 | d->autoAssignThumbnailProvider(); | 974 | d->autoAssignThumbnailProvider(); | ||
973 | toggleSideBar(d->sideBarVisibility()); | 975 | toggleSideBar(d->sideBarVisibility()); | ||
rkflx: Unrelated whitespace change, please revert. | |||||
974 | toggleStatusBar(d->statusBarVisibility()); | 976 | toggleStatusBar(d->statusBarVisibility()); | ||
975 | 977 | | |||
976 | emit viewModeChanged(); | 978 | emit viewModeChanged(); | ||
977 | } | 979 | } | ||
978 | 980 | | |||
979 | void MainWindow::slotThumbnailViewIndexActivated(const QModelIndex& index) | 981 | void MainWindow::slotThumbnailViewIndexActivated(const QModelIndex& index) | ||
980 | { | 982 | { | ||
981 | if (!index.isValid()) { | 983 | if (!index.isValid()) { | ||
▲ Show 20 Lines • Show All 519 Lines • ▼ Show 20 Line(s) | 1502 | default: // cancel | |||
1501 | return false; | 1503 | return false; | ||
1502 | } | 1504 | } | ||
1503 | } | 1505 | } | ||
1504 | 1506 | | |||
1505 | void MainWindow::showConfigDialog() | 1507 | void MainWindow::showConfigDialog() | ||
1506 | { | 1508 | { | ||
1507 | // Save first so changes like thumbnail zoom level are not lost when reloading config | 1509 | // Save first so changes like thumbnail zoom level are not lost when reloading config | ||
1508 | saveConfig(); | 1510 | saveConfig(); | ||
1509 | 1511 | | |||
rkflx: Unrelated whitespace change, please revert. | |||||
1510 | DialogGuard<ConfigDialog> dialog(this); | 1512 | DialogGuard<ConfigDialog> dialog(this); | ||
1511 | connect(dialog.data(), SIGNAL(settingsChanged(QString)), SLOT(loadConfig())); | 1513 | connect(dialog.data(), SIGNAL(settingsChanged(QString)), SLOT(loadConfig())); | ||
1512 | dialog->exec(); | 1514 | dialog->exec(); | ||
1513 | } | 1515 | } | ||
1514 | 1516 | | |||
1515 | void MainWindow::configureShortcuts() | 1517 | void MainWindow::configureShortcuts() | ||
1516 | { | 1518 | { | ||
1517 | guiFactory()->configureShortcuts(); | 1519 | guiFactory()->configureShortcuts(); | ||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | 1646 | #ifdef Q_OS_OSX | |||
1646 | * handle Mac OS X file open events (only exist on OS X) | 1648 | * handle Mac OS X file open events (only exist on OS X) | ||
1647 | */ | 1649 | */ | ||
1648 | if (event->type() == QEvent::FileOpen) { | 1650 | if (event->type() == QEvent::FileOpen) { | ||
1649 | QFileOpenEvent *fileOpenEvent = static_cast<QFileOpenEvent*>(event); | 1651 | QFileOpenEvent *fileOpenEvent = static_cast<QFileOpenEvent*>(event); | ||
1650 | openUrl(fileOpenEvent->url()); | 1652 | openUrl(fileOpenEvent->url()); | ||
1651 | return true; | 1653 | return true; | ||
1652 | } | 1654 | } | ||
1653 | #endif | 1655 | #endif | ||
1656 | if (obj == d->mThumbnailView->viewport()) { | ||||
1657 | switch(event->type()) { | ||||
1658 | case QEvent::MouseButtonPress: | ||||
1659 | case QEvent::MouseButtonDblClick: | ||||
1660 | mouseButtonNavigate(static_cast<QMouseEvent*>(event)); | ||||
1661 | break; | ||||
1662 | default: ; | ||||
1663 | } | ||||
1664 | } | ||||
1654 | return false; | 1665 | return false; | ||
1655 | } | 1666 | } | ||
1656 | 1667 | | |||
1668 | void MainWindow::mousePressEvent(QMouseEvent *event) | ||||
1669 | { | ||||
1670 | mouseButtonNavigate(event); | ||||
1671 | KXmlGuiWindow::mousePressEvent(event); | ||||
1672 | } | ||||
1673 | | ||||
1674 | void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) | ||||
1675 | { | ||||
1676 | mouseButtonNavigate(event); | ||||
1677 | KXmlGuiWindow::mouseDoubleClickEvent(event); | ||||
1678 | } | ||||
1679 | | ||||
1680 | void MainWindow::mouseButtonNavigate(QMouseEvent *event) | ||||
1681 | { | ||||
1682 | switch(event->button()) { | ||||
1683 | case Qt::ForwardButton: | ||||
1684 | if (d->mGoToNextAction->isEnabled()) { | ||||
1685 | d->mGoToNextAction->trigger(); | ||||
1686 | return; | ||||
1687 | } | ||||
1688 | break; | ||||
1689 | case Qt::BackButton: | ||||
1690 | if (d->mGoToPreviousAction->isEnabled()) { | ||||
1691 | d->mGoToPreviousAction->trigger(); | ||||
1692 | return; | ||||
1693 | } | ||||
1694 | break; | ||||
1695 | default: ; | ||||
1696 | } | ||||
1697 | } | ||||
1698 | | ||||
1657 | void MainWindow::setDistractionFreeMode(bool value) | 1699 | void MainWindow::setDistractionFreeMode(bool value) | ||
1658 | { | 1700 | { | ||
1659 | d->mFullScreenContent->setDistractionFreeMode(value); | 1701 | d->mFullScreenContent->setDistractionFreeMode(value); | ||
1660 | } | 1702 | } | ||
1661 | 1703 | | |||
1662 | void MainWindow::saveProperties(KConfigGroup& group) | 1704 | void MainWindow::saveProperties(KConfigGroup& group) | ||
1663 | { | 1705 | { | ||
1664 | group.writeEntry(SESSION_CURRENT_PAGE_KEY, int(d->mCurrentMainPageId)); | 1706 | group.writeEntry(SESSION_CURRENT_PAGE_KEY, int(d->mCurrentMainPageId)); | ||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |
Unrelated whitespace change, please revert.