Changeset View
Changeset View
Standalone View
Standalone View
app/mainwindow.cpp
Show All 32 Lines | |||||
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 | #include <QMouseEvent> | ||
38 | #ifdef Q_OS_OSX | 38 | #ifdef Q_OS_OSX | ||
39 | #include <QFileOpenEvent> | 39 | #include <QFileOpenEvent> | ||
40 | #endif | 40 | #endif | ||
41 | #include <QJsonArray> | ||||
42 | #include <QJsonObject> | ||||
41 | 43 | | |||
42 | // KDE | 44 | // KDE | ||
43 | #include <KActionCategory> | 45 | #include <KActionCategory> | ||
44 | #include <KActionCollection> | 46 | #include <KActionCollection> | ||
45 | #include <QFileDialog> | 47 | #include <QFileDialog> | ||
46 | #include <KFileItem> | 48 | #include <KFileItem> | ||
47 | #include <KLocalizedString> | 49 | #include <KLocalizedString> | ||
48 | #include <KMessageBox> | 50 | #include <KMessageBox> | ||
49 | #include <KNotificationRestrictions> | 51 | #include <KNotificationRestrictions> | ||
50 | #include <KProtocolManager> | 52 | #include <KProtocolManager> | ||
51 | #include <KLinkItemSelectionModel> | 53 | #include <KLinkItemSelectionModel> | ||
52 | #include <KRecentFilesAction> | 54 | #include <KRecentFilesAction> | ||
53 | #include <KStandardShortcut> | 55 | #include <KStandardShortcut> | ||
54 | #include <KToggleFullScreenAction> | 56 | #include <KToggleFullScreenAction> | ||
55 | #include <KUrlComboBox> | 57 | #include <KUrlComboBox> | ||
56 | #include <KUrlNavigator> | 58 | #include <KUrlNavigator> | ||
57 | #include <KToolBar> | 59 | #include <KToolBar> | ||
58 | #include <KXMLGUIFactory> | 60 | #include <KXMLGUIFactory> | ||
59 | #include <KDirLister> | 61 | #include <KDirLister> | ||
62 | #include <PurposeWidgets/Menu> | ||||
63 | #include <Purpose/AlternativesModel> | ||||
60 | 64 | | |||
61 | // Local | 65 | // Local | ||
62 | #include "configdialog.h" | 66 | #include "configdialog.h" | ||
63 | #include "documentinfoprovider.h" | 67 | #include "documentinfoprovider.h" | ||
64 | #include "viewmainpage.h" | 68 | #include "viewmainpage.h" | ||
65 | #include "fileopscontextmanageritem.h" | 69 | #include "fileopscontextmanageritem.h" | ||
66 | #include "folderviewcontextmanageritem.h" | 70 | #include "folderviewcontextmanageritem.h" | ||
67 | #include "fullscreencontent.h" | 71 | #include "fullscreencontent.h" | ||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 186 | #endif | |||
190 | QAction * mGoToNextAction; | 194 | QAction * mGoToNextAction; | ||
191 | QAction * mGoToFirstAction; | 195 | QAction * mGoToFirstAction; | ||
192 | QAction * mGoToLastAction; | 196 | QAction * mGoToLastAction; | ||
193 | KToggleAction* mToggleSideBarAction; | 197 | KToggleAction* mToggleSideBarAction; | ||
194 | QAction* mFullScreenAction; | 198 | QAction* mFullScreenAction; | ||
195 | QAction * mToggleSlideShowAction; | 199 | QAction * mToggleSlideShowAction; | ||
196 | KToggleAction* mShowMenuBarAction; | 200 | KToggleAction* mShowMenuBarAction; | ||
197 | KToggleAction* mShowStatusBarAction; | 201 | KToggleAction* mShowStatusBarAction; | ||
202 | Purpose::Menu* mShareMenu; | ||||
203 | KToolBarPopupAction* mShareAction; | ||||
198 | #ifdef KIPI_FOUND | 204 | #ifdef KIPI_FOUND | ||
199 | KIPIExportAction* mKIPIExportAction; | 205 | KIPIExportAction* mKIPIExportAction; | ||
200 | #endif | 206 | #endif | ||
201 | 207 | | |||
202 | SortedDirModel* mDirModel; | 208 | SortedDirModel* mDirModel; | ||
203 | DocumentOnlyProxyModel* mThumbnailBarModel; | 209 | DocumentOnlyProxyModel* mThumbnailBarModel; | ||
204 | KLinkItemSelectionModel* mThumbnailBarSelectionModel; | 210 | KLinkItemSelectionModel* mThumbnailBarSelectionModel; | ||
205 | ContextManager* mContextManager; | 211 | ContextManager* mContextManager; | ||
▲ Show 20 Lines • Show All 293 Lines • ▼ Show 20 Line(s) | 375 | { | |||
499 | view->addAction(KStandardAction::Preferences, q, | 505 | view->addAction(KStandardAction::Preferences, q, | ||
500 | SLOT(showConfigDialog())); | 506 | SLOT(showConfigDialog())); | ||
501 | 507 | | |||
502 | view->addAction(KStandardAction::ConfigureToolbars, q, | 508 | view->addAction(KStandardAction::ConfigureToolbars, q, | ||
503 | SLOT(configureToolbars())); | 509 | SLOT(configureToolbars())); | ||
504 | 510 | | |||
505 | #ifdef KIPI_FOUND | 511 | #ifdef KIPI_FOUND | ||
506 | mKIPIExportAction = new KIPIExportAction(q); | 512 | mKIPIExportAction = new KIPIExportAction(q); | ||
507 | actionCollection->addAction("kipi_export", mKIPIExportAction); | | |||
508 | #endif | 513 | #endif | ||
514 | | ||||
515 | mShareAction = new KToolBarPopupAction(QIcon::fromTheme("document-share"), "Share", q); | ||||
ngraham: This needs `setDelayed(false);` set or else when it's added to the toolbar, clicking on it most… | |||||
516 | mShareAction->setDelayed(false); | ||||
517 | actionCollection->addAction("share", mShareAction); | ||||
518 | mShareMenu = new Purpose::Menu(q); | ||||
519 | mShareAction->setMenu(mShareMenu); | ||||
509 | } | 520 | } | ||
510 | 521 | | |||
511 | void setupUndoActions() | 522 | void setupUndoActions() | ||
512 | { | 523 | { | ||
513 | // There is no KUndoGroup similar to KUndoStack. This code basically | 524 | // There is no KUndoGroup similar to KUndoStack. This code basically | ||
514 | // does the same as KUndoStack, but for the KUndoGroup actions. | 525 | // does the same as KUndoStack, but for the KUndoGroup actions. | ||
515 | QUndoGroup* undoGroup = DocumentFactory::instance()->undoGroup(); | 526 | QUndoGroup* undoGroup = DocumentFactory::instance()->undoGroup(); | ||
516 | QAction* action; | 527 | QAction* action; | ||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Line(s) | 711 | if (mCurrentMainPageId != ViewMainPageId | |||
703 | canSave = false; | 714 | canSave = false; | ||
704 | } | 715 | } | ||
705 | } | 716 | } | ||
706 | 717 | | |||
707 | KActionCollection* actionCollection = q->actionCollection(); | 718 | KActionCollection* actionCollection = q->actionCollection(); | ||
708 | actionCollection->action("file_save")->setEnabled(canSave && isModified); | 719 | actionCollection->action("file_save")->setEnabled(canSave && isModified); | ||
709 | actionCollection->action("file_save_as")->setEnabled(canSave); | 720 | actionCollection->action("file_save_as")->setEnabled(canSave); | ||
710 | actionCollection->action("file_print")->setEnabled(isRasterImage); | 721 | actionCollection->action("file_print")->setEnabled(isRasterImage); | ||
722 | | ||||
723 | if (url.isEmpty()) { | ||||
724 | mShareAction->setEnabled(false); | ||||
725 | } else { | ||||
726 | mShareAction->setEnabled(true); | ||||
727 | mShareMenu->model()->setInputData(QJsonObject{ | ||||
728 | { QStringLiteral("mimeType"), MimeTypeUtils::urlMimeType(url) }, | ||||
729 | { QStringLiteral("urls"), QJsonArray{url.toString()} } | ||||
730 | }); | ||||
731 | mShareMenu->model()->setPluginType( QStringLiteral("Export") ); | ||||
732 | mShareMenu->reload(); | ||||
733 | } | ||||
711 | } | 734 | } | ||
712 | 735 | | |||
713 | bool sideBarVisibility() const | 736 | bool sideBarVisibility() const | ||
714 | { | 737 | { | ||
715 | switch (mCurrentMainPageId) { | 738 | switch (mCurrentMainPageId) { | ||
716 | case StartMainPageId: | 739 | case StartMainPageId: | ||
717 | GV_WARN_AND_RETURN_VALUE(false, "Sidebar not implemented on start page"); | 740 | GV_WARN_AND_RETURN_VALUE(false, "Sidebar not implemented on start page"); | ||
718 | break; | 741 | break; | ||
▲ Show 20 Lines • Show All 1074 Lines • Show Last 20 Lines |
This needs setDelayed(false); set or else when it's added to the toolbar, clicking on it most of the button does nothing (you need to click on the arrow to make the menu appear).