Changeset View
Standalone View
app/mainwindow.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | |||||
80 | #include "thumbnailviewhelper.h" | 80 | #include "thumbnailviewhelper.h" | ||
81 | #include "browsemainpage.h" | 81 | #include "browsemainpage.h" | ||
82 | #include <lib/hud/hudbuttonbox.h> | 82 | #include <lib/hud/hudbuttonbox.h> | ||
83 | #include <lib/archiveutils.h> | 83 | #include <lib/archiveutils.h> | ||
84 | #include <lib/contextmanager.h> | 84 | #include <lib/contextmanager.h> | ||
85 | #include <lib/disabledactionshortcutmonitor.h> | 85 | #include <lib/disabledactionshortcutmonitor.h> | ||
86 | #include <lib/document/documentfactory.h> | 86 | #include <lib/document/documentfactory.h> | ||
87 | #include <lib/documentonlyproxymodel.h> | 87 | #include <lib/documentonlyproxymodel.h> | ||
88 | #include <lib/eventwatcher.h> | | |||
89 | #include <lib/gvdebug.h> | 88 | #include <lib/gvdebug.h> | ||
90 | #include <lib/gwenviewconfig.h> | 89 | #include <lib/gwenviewconfig.h> | ||
91 | #include <lib/mimetypeutils.h> | 90 | #include <lib/mimetypeutils.h> | ||
92 | #include <lib/print/printhelper.h> | 91 | #include <lib/print/printhelper.h> | ||
93 | #include <lib/slideshow.h> | 92 | #include <lib/slideshow.h> | ||
94 | #include <lib/signalblocker.h> | 93 | #include <lib/signalblocker.h> | ||
95 | #include <lib/semanticinfo/sorteddirmodel.h> | 94 | #include <lib/semanticinfo/sorteddirmodel.h> | ||
96 | #include <lib/thumbnailprovider/thumbnailprovider.h> | 95 | #include <lib/thumbnailprovider/thumbnailprovider.h> | ||
Show All 11 Lines | |||||
108 | #define LOG(x) qDebug() << x | 107 | #define LOG(x) qDebug() << x | ||
109 | #else | 108 | #else | ||
110 | #define LOG(x) ; | 109 | #define LOG(x) ; | ||
111 | #endif | 110 | #endif | ||
112 | 111 | | |||
113 | static const int BROWSE_PRELOAD_DELAY = 1000; | 112 | static const int BROWSE_PRELOAD_DELAY = 1000; | ||
114 | static const int VIEW_PRELOAD_DELAY = 100; | 113 | static const int VIEW_PRELOAD_DELAY = 100; | ||
115 | 114 | | |||
116 | static const char* BROWSE_MODE_SIDE_BAR_GROUP = "SideBar-BrowseMode"; | | |||
117 | static const char* VIEW_MODE_SIDE_BAR_GROUP = "SideBar-ViewMode"; | | |||
118 | static const char* FULLSCREEN_MODE_SIDE_BAR_GROUP = "SideBar-FullScreenMode"; | | |||
119 | static const char* SIDE_BAR_IS_VISIBLE_KEY = "IsVisible"; | | |||
120 | | ||||
121 | static const char* SESSION_CURRENT_PAGE_KEY = "Page"; | 115 | static const char* SESSION_CURRENT_PAGE_KEY = "Page"; | ||
122 | static const char* SESSION_URL_KEY = "Url"; | 116 | static const char* SESSION_URL_KEY = "Url"; | ||
123 | 117 | | |||
124 | enum MainPageId { | 118 | enum MainPageId { | ||
125 | StartMainPageId, | 119 | StartMainPageId, | ||
126 | BrowseMainPageId, | 120 | BrowseMainPageId, | ||
127 | ViewMainPageId | 121 | ViewMainPageId | ||
128 | }; | 122 | }; | ||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 217 | { | |||
224 | mFullScreenContent = new FullScreenContent(q, mGvCore); | 218 | mFullScreenContent = new FullScreenContent(q, mGvCore); | ||
225 | connect(mContextManager, SIGNAL(currentUrlChanged(QUrl)), mFullScreenContent, SLOT(setCurrentUrl(QUrl))); | 219 | connect(mContextManager, SIGNAL(currentUrlChanged(QUrl)), mFullScreenContent, SLOT(setCurrentUrl(QUrl))); | ||
226 | 220 | | |||
227 | mCentralSplitter = new Splitter(Qt::Horizontal, q); | 221 | mCentralSplitter = new Splitter(Qt::Horizontal, q); | ||
228 | q->setCentralWidget(mCentralSplitter); | 222 | q->setCentralWidget(mCentralSplitter); | ||
229 | 223 | | |||
230 | // Left side of splitter | 224 | // Left side of splitter | ||
231 | mSideBar = new SideBar(mCentralSplitter); | 225 | mSideBar = new SideBar(mCentralSplitter); | ||
232 | EventWatcher::install(mSideBar, QList<QEvent::Type>() << QEvent::Show << QEvent::Hide, | | |||
233 | q, SLOT(updateToggleSideBarAction())); | | |||
234 | 226 | | |||
235 | // Right side of splitter | 227 | // Right side of splitter | ||
236 | mContentWidget = new QWidget(mCentralSplitter); | 228 | mContentWidget = new QWidget(mCentralSplitter); | ||
237 | 229 | | |||
238 | mSaveBar = new SaveBar(mContentWidget, q->actionCollection()); | 230 | mSaveBar = new SaveBar(mContentWidget, q->actionCollection()); | ||
239 | connect(mContextManager, SIGNAL(currentUrlChanged(QUrl)), mSaveBar, SLOT(setCurrentUrl(QUrl))); | 231 | connect(mContextManager, SIGNAL(currentUrlChanged(QUrl)), mSaveBar, SLOT(setCurrentUrl(QUrl))); | ||
240 | mViewStackedWidget = new QStackedWidget(mContentWidget); | 232 | mViewStackedWidget = new QStackedWidget(mContentWidget); | ||
241 | QVBoxLayout* layout = new QVBoxLayout(mContentWidget); | 233 | QVBoxLayout* layout = new QVBoxLayout(mContentWidget); | ||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Line(s) | 348 | { | |||
440 | 432 | | |||
441 | action = view->addAction("go_start_page", q, SLOT(showStartMainPage())); | 433 | action = view->addAction("go_start_page", q, SLOT(showStartMainPage())); | ||
442 | action->setPriority(QAction::LowPriority); | 434 | action->setPriority(QAction::LowPriority); | ||
443 | action->setIcon(QIcon::fromTheme("go-home")); | 435 | action->setIcon(QIcon::fromTheme("go-home")); | ||
444 | action->setText(i18nc("@action", "Start Page")); | 436 | action->setText(i18nc("@action", "Start Page")); | ||
445 | action->setToolTip(i18nc("@info:tooltip", "Open the start page")); | 437 | action->setToolTip(i18nc("@info:tooltip", "Open the start page")); | ||
446 | 438 | | |||
447 | mToggleSideBarAction = view->add<KToggleAction>("toggle_sidebar"); | 439 | mToggleSideBarAction = view->add<KToggleAction>("toggle_sidebar"); | ||
448 | connect(mToggleSideBarAction, SIGNAL(toggled(bool)), | 440 | connect(mToggleSideBarAction, &KToggleAction::triggered, q, &MainWindow::toggleSideBar); | ||
muhlenpfordt: Using the `triggered()` signal here (equal to `KStandardAction::ShowStatusbar`) prevents re… | |||||
449 | q, SLOT(toggleSideBar(bool))); | | |||
450 | mToggleSideBarAction->setIcon(QIcon::fromTheme("view-sidetree")); | 441 | mToggleSideBarAction->setIcon(QIcon::fromTheme("view-sidetree")); | ||
451 | actionCollection->setDefaultShortcut(mToggleSideBarAction, Qt::Key_F4); | 442 | actionCollection->setDefaultShortcut(mToggleSideBarAction, Qt::Key_F4); | ||
452 | mToggleSideBarAction->setText(i18nc("@action", "Sidebar")); | 443 | mToggleSideBarAction->setText(i18nc("@action", "Sidebar")); | ||
453 | connect(mBrowseMainPage->toggleSideBarButton(), SIGNAL(clicked()), | 444 | connect(mBrowseMainPage->toggleSideBarButton(), SIGNAL(clicked()), | ||
454 | mToggleSideBarAction, SLOT(trigger())); | 445 | mToggleSideBarAction, SLOT(trigger())); | ||
455 | connect(mViewMainPage->toggleSideBarButton(), SIGNAL(clicked()), | 446 | connect(mViewMainPage->toggleSideBarButton(), SIGNAL(clicked()), | ||
456 | mToggleSideBarAction, SLOT(trigger())); | 447 | mToggleSideBarAction, SLOT(trigger())); | ||
457 | 448 | | |||
▲ Show 20 Lines • Show All 221 Lines • ▼ Show 20 Line(s) | 655 | { | |||
679 | } | 670 | } | ||
680 | 671 | | |||
681 | KActionCollection* actionCollection = q->actionCollection(); | 672 | KActionCollection* actionCollection = q->actionCollection(); | ||
682 | actionCollection->action("file_save")->setEnabled(canSave && isModified); | 673 | actionCollection->action("file_save")->setEnabled(canSave && isModified); | ||
683 | actionCollection->action("file_save_as")->setEnabled(canSave); | 674 | actionCollection->action("file_save_as")->setEnabled(canSave); | ||
684 | actionCollection->action("file_print")->setEnabled(isRasterImage); | 675 | actionCollection->action("file_print")->setEnabled(isRasterImage); | ||
685 | } | 676 | } | ||
686 | 677 | | |||
687 | const char* sideBarConfigGroupName() const | 678 | bool sideBarVisibility() const | ||
688 | { | 679 | { | ||
689 | const char* name = 0; | | |||
690 | switch (mCurrentMainPageId) { | 680 | switch (mCurrentMainPageId) { | ||
691 | case StartMainPageId: | 681 | case StartMainPageId: | ||
692 | GV_WARN_AND_RETURN_VALUE(BROWSE_MODE_SIDE_BAR_GROUP, "mCurrentMainPageId == 'StartMainPageId'"); | 682 | GV_WARN_AND_RETURN_VALUE(false, "Sidebar not implemented on start page"); | ||
693 | break; | 683 | break; | ||
694 | case BrowseMainPageId: | 684 | case BrowseMainPageId: | ||
695 | name = BROWSE_MODE_SIDE_BAR_GROUP; | 685 | return GwenviewConfig::sideBarVisibleBrowseMode(); | ||
696 | break; | 686 | break; | ||
697 | case ViewMainPageId: | 687 | case ViewMainPageId: | ||
698 | name = q->isFullScreen() | 688 | return q->isFullScreen() | ||
699 | ? FULLSCREEN_MODE_SIDE_BAR_GROUP | 689 | ? GwenviewConfig::sideBarVisibleViewModeFullScreen() | ||
700 | : VIEW_MODE_SIDE_BAR_GROUP; | 690 | : GwenviewConfig::sideBarVisibleViewMode(); | ||
701 | break; | 691 | break; | ||
702 | } | 692 | } | ||
703 | return name; | | |||
704 | } | | |||
705 | 693 | | |||
706 | void loadSideBarConfig() | 694 | return false; | ||
707 | { | | |||
708 | static QMap<const char*, bool> defaultVisibility; | | |||
709 | if (defaultVisibility.isEmpty()) { | | |||
710 | defaultVisibility[BROWSE_MODE_SIDE_BAR_GROUP] = true; | | |||
711 | defaultVisibility[VIEW_MODE_SIDE_BAR_GROUP] = true; | | |||
712 | defaultVisibility[FULLSCREEN_MODE_SIDE_BAR_GROUP] = false; | | |||
713 | } | | |||
714 | | ||||
715 | const char* name = sideBarConfigGroupName(); | | |||
716 | KConfigGroup group(KSharedConfig::openConfig(), name); | | |||
717 | mSideBar->setVisible(group.readEntry(SIDE_BAR_IS_VISIBLE_KEY, defaultVisibility[name])); | | |||
718 | mSideBar->setCurrentPage(GwenviewConfig::sideBarPage()); | | |||
719 | q->updateToggleSideBarAction(); | | |||
720 | } | 695 | } | ||
721 | 696 | | |||
722 | void saveSideBarConfig() const | 697 | void saveSideBarVisibility(const bool visible) | ||
Just noticed that in D10577#inline-50448 I suggested save instead of set, somehow I missed this in the final check. If you like it better too, change it here and git push the corresponding change for the statusbar. rkflx: Just noticed that in D10577#inline-50448 I suggested `save` instead of `set`, somehow I missed… | |||||
723 | { | 698 | { | ||
724 | KConfigGroup group(KSharedConfig::openConfig(), sideBarConfigGroupName()); | 699 | switch (mCurrentMainPageId) { | ||
725 | group.writeEntry(SIDE_BAR_IS_VISIBLE_KEY, mSideBar->isVisible()); | 700 | case StartMainPageId: | ||
726 | GwenviewConfig::setSideBarPage(mSideBar->currentPage()); | 701 | GV_WARN_AND_RETURN("Sidebar not implemented on start page"); | ||
702 | break; | ||||
703 | case BrowseMainPageId: | ||||
704 | GwenviewConfig::setSideBarVisibleBrowseMode(visible); | ||||
705 | break; | ||||
706 | case ViewMainPageId: | ||||
707 | q->isFullScreen() | ||||
708 | ? GwenviewConfig::setSideBarVisibleViewModeFullScreen(visible) | ||||
709 | : GwenviewConfig::setSideBarVisibleViewMode(visible); | ||||
710 | break; | ||||
711 | } | ||||
727 | } | 712 | } | ||
728 | 713 | | |||
729 | bool statusBarVisibility() const | 714 | bool statusBarVisibility() const | ||
730 | { | 715 | { | ||
731 | switch (mCurrentMainPageId) { | 716 | switch (mCurrentMainPageId) { | ||
732 | case StartMainPageId: | 717 | case StartMainPageId: | ||
733 | GV_WARN_AND_RETURN_VALUE(false, "Statusbar not implemented on start page"); | 718 | GV_WARN_AND_RETURN_VALUE(false, "Statusbar not implemented on start page"); | ||
734 | break; | 719 | break; | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 794 | { | |||
825 | d->setupFullScreenContent(); | 810 | d->setupFullScreenContent(); | ||
826 | d->updateActions(); | 811 | d->updateActions(); | ||
827 | updatePreviousNextActions(); | 812 | updatePreviousNextActions(); | ||
828 | d->mSaveBar->initActionDependentWidgets(); | 813 | d->mSaveBar->initActionDependentWidgets(); | ||
829 | 814 | | |||
830 | createGUI(); | 815 | createGUI(); | ||
831 | loadConfig(); | 816 | loadConfig(); | ||
832 | 817 | | |||
833 | connect(DocumentFactory::instance(), SIGNAL(modifiedDocumentListChanged()), | 818 | connect(DocumentFactory::instance(), SIGNAL(modifiedDocumentListChanged()), | ||
834 | SLOT(slotModifiedDocumentListChanged())); | 819 | SLOT(slotModifiedDocumentListChanged())); | ||
835 | 820 | | |||
836 | #ifdef KIPI_FOUND | 821 | #ifdef KIPI_FOUND | ||
837 | d->mKIPIInterface = new KIPIInterface(this); | 822 | d->mKIPIInterface = new KIPIInterface(this); | ||
d->mSideBar everywhere makes me wonder whether this could be moved to, well, the SideBar. And GwenviewConfig:: is all over the codebase already anyway. Also, your testplan missed to mention that part (it works, though ;) rkflx: `d->mSideBar` everywhere makes me wonder whether this could be moved to, well, the `SideBar`. | |||||
During the first addPage() the currentChanged signal is emitted, so it should not be connected before that (i.e. not in the SideBar constructor). Forgot to add a comment on that. muhlenpfordt: During the first `addPage()` the `currentChanged` signal is emitted, so it should not be… | |||||
838 | d->mKIPIExportAction->setKIPIInterface(d->mKIPIInterface); | 823 | d->mKIPIExportAction->setKIPIInterface(d->mKIPIInterface); | ||
839 | #endif | 824 | #endif | ||
840 | setAutoSaveSettings(); | 825 | setAutoSaveSettings(); | ||
841 | #ifdef Q_OS_OSX | 826 | #ifdef Q_OS_OSX | ||
842 | qApp->installEventFilter(this); | 827 | qApp->installEventFilter(this); | ||
843 | #endif | 828 | #endif | ||
844 | } | 829 | } | ||
845 | 830 | | |||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 892 | { | |||
909 | // We need to wait until we have listed all images in the dirlister to | 894 | // We need to wait until we have listed all images in the dirlister to | ||
910 | // start the slideshow because the SlideShow objects needs an image list to | 895 | // start the slideshow because the SlideShow objects needs an image list to | ||
911 | // work. | 896 | // work. | ||
912 | d->mStartSlideShowWhenDirListerCompleted = true; | 897 | d->mStartSlideShowWhenDirListerCompleted = true; | ||
913 | } | 898 | } | ||
914 | 899 | | |||
915 | void MainWindow::setActiveViewModeAction(QAction* action) | 900 | void MainWindow::setActiveViewModeAction(QAction* action) | ||
916 | { | 901 | { | ||
917 | if (d->mCurrentMainPageId != StartMainPageId) { | | |||
918 | d->saveSideBarConfig(); | | |||
919 | } | | |||
920 | if (action == d->mViewAction) { | 902 | if (action == d->mViewAction) { | ||
921 | d->mCurrentMainPageId = ViewMainPageId; | 903 | d->mCurrentMainPageId = ViewMainPageId; | ||
922 | // Switching to view mode | 904 | // Switching to view mode | ||
923 | d->mViewStackedWidget->setCurrentWidget(d->mViewMainPage); | 905 | d->mViewStackedWidget->setCurrentWidget(d->mViewMainPage); | ||
924 | openSelectedDocuments(); | 906 | openSelectedDocuments(); | ||
925 | d->mPreloadDirectionIsForward = true; | 907 | d->mPreloadDirectionIsForward = true; | ||
926 | QTimer::singleShot(VIEW_PRELOAD_DELAY, this, SLOT(preloadNextUrl())); | 908 | QTimer::singleShot(VIEW_PRELOAD_DELAY, this, SLOT(preloadNextUrl())); | ||
927 | } else { | 909 | } else { | ||
928 | d->mCurrentMainPageId = BrowseMainPageId; | 910 | d->mCurrentMainPageId = BrowseMainPageId; | ||
929 | // Switching to browse mode | 911 | // Switching to browse mode | ||
930 | d->mViewStackedWidget->setCurrentWidget(d->mBrowseMainPage); | 912 | d->mViewStackedWidget->setCurrentWidget(d->mBrowseMainPage); | ||
931 | if (!d->mViewMainPage->isEmpty() | 913 | if (!d->mViewMainPage->isEmpty() | ||
932 | && KProtocolManager::supportsListing(d->mViewMainPage->url())) { | 914 | && KProtocolManager::supportsListing(d->mViewMainPage->url())) { | ||
933 | // Reset the view to spare resources, but don't do it if we can't | 915 | // Reset the view to spare resources, but don't do it if we can't | ||
934 | // browse the url, otherwise if the user starts Gwenview this way: | 916 | // browse the url, otherwise if the user starts Gwenview this way: | ||
935 | // gwenview http://example.com/example.png | 917 | // gwenview http://example.com/example.png | ||
936 | // and switch to browse mode, switching back to view mode won't bring | 918 | // and switch to browse mode, switching back to view mode won't bring | ||
937 | // his image back. | 919 | // his image back. | ||
938 | d->mViewMainPage->reset(); | 920 | d->mViewMainPage->reset(); | ||
939 | } | 921 | } | ||
940 | setCaption(QString()); | 922 | setCaption(QString()); | ||
941 | } | 923 | } | ||
942 | d->loadSideBarConfig(); | | |||
943 | d->autoAssignThumbnailProvider(); | 924 | d->autoAssignThumbnailProvider(); | ||
925 | toggleSideBar(d->sideBarVisibility()); | ||||
944 | toggleStatusBar(d->statusBarVisibility()); | 926 | toggleStatusBar(d->statusBarVisibility()); | ||
945 | 927 | | |||
946 | emit viewModeChanged(); | 928 | emit viewModeChanged(); | ||
947 | } | 929 | } | ||
948 | 930 | | |||
949 | void MainWindow::slotThumbnailViewIndexActivated(const QModelIndex& index) | 931 | void MainWindow::slotThumbnailViewIndexActivated(const QModelIndex& index) | ||
950 | { | 932 | { | ||
951 | if (!index.isValid()) { | 933 | if (!index.isValid()) { | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 995 | if (d->mCurrentMainPageId == BrowseMainPageId) { | |||
1015 | url = KIO::upUrl(url); | 997 | url = KIO::upUrl(url); | ||
1016 | openDirUrl(url); | 998 | openDirUrl(url); | ||
1017 | } else { | 999 | } else { | ||
1018 | d->mBrowseAction->trigger(); | 1000 | d->mBrowseAction->trigger(); | ||
1019 | } | 1001 | } | ||
1020 | } | 1002 | } | ||
1021 | 1003 | | |||
1022 | void MainWindow::showStartMainPage() | 1004 | void MainWindow::showStartMainPage() | ||
1023 | { | 1005 | { | ||
1024 | if (d->mCurrentMainPageId != StartMainPageId) { | | |||
1025 | d->saveSideBarConfig(); | | |||
1026 | d->mCurrentMainPageId = StartMainPageId; | 1006 | d->mCurrentMainPageId = StartMainPageId; | ||
rkflx: I don't see this kind of check anywhere else, it's kind of over the top now… | |||||
1027 | } | | |||
1028 | d->setActionsDisabledOnStartMainPageEnabled(false); | 1007 | d->setActionsDisabledOnStartMainPageEnabled(false); | ||
1029 | 1008 | | |||
1030 | d->mSideBar->hide(); | 1009 | d->mSideBar->hide(); | ||
1031 | d->mViewStackedWidget->setCurrentWidget(d->mStartMainPage); | 1010 | d->mViewStackedWidget->setCurrentWidget(d->mStartMainPage); | ||
1032 | 1011 | | |||
1033 | d->updateActions(); | 1012 | d->updateActions(); | ||
1034 | updatePreviousNextActions(); | 1013 | updatePreviousNextActions(); | ||
1035 | d->mContextManager->setCurrentDirUrl(QUrl()); | 1014 | d->mContextManager->setCurrentDirUrl(QUrl()); | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 1068 | if (url == currentUrl) { | |||
1097 | case StartMainPageId: | 1076 | case StartMainPageId: | ||
1098 | break; | 1077 | break; | ||
1099 | } | 1078 | } | ||
1100 | } else { | 1079 | } else { | ||
1101 | openDirUrl(url); | 1080 | openDirUrl(url); | ||
1102 | } | 1081 | } | ||
1103 | } | 1082 | } | ||
1104 | 1083 | | |||
1105 | void MainWindow::toggleSideBar(bool on) | 1084 | void MainWindow::toggleSideBar(bool visible) | ||
1106 | { | 1085 | { | ||
1107 | d->mSideBar->setVisible(on); | 1086 | d->mToggleSideBarAction->setChecked(visible); | ||
1087 | d->saveSideBarVisibility(visible); | ||||
1088 | d->mSideBar->setVisible(visible); | ||||
1089 | | ||||
1090 | const QString text = QApplication::isRightToLeft() | ||||
1091 | ? QString::fromUtf8(visible ? "▮→" : "▮←") | ||||
1092 | : QString::fromUtf8(visible ? "▮←" : "▮→"); | ||||
1093 | const QString toolTip = visible | ||||
1094 | ? i18nc("@info:tooltip", "Hide sidebar") | ||||
1095 | : i18nc("@info:tooltip", "Show sidebar"); | ||||
1096 | | ||||
1097 | const QList<QToolButton*> buttonList { | ||||
rkflx: Add space before `{`. | |||||
1098 | d->mBrowseMainPage->toggleSideBarButton(), | ||||
1099 | d->mViewMainPage->toggleSideBarButton() | ||||
1100 | }; | ||||
1101 | for (auto button : buttonList) { | ||||
1102 | button->setText(text); | ||||
1103 | button->setToolTip(toolTip); | ||||
1104 | } | ||||
1108 | } | 1105 | } | ||
1109 | 1106 | | |||
1110 | void MainWindow::toggleStatusBar(bool visible) | 1107 | void MainWindow::toggleStatusBar(bool visible) | ||
1111 | { | 1108 | { | ||
1112 | d->mShowStatusBarAction->setChecked(visible); | 1109 | d->mShowStatusBarAction->setChecked(visible); | ||
1113 | d->setStatusBarVisibility(visible); | 1110 | d->setStatusBarVisibility(visible); | ||
1114 | 1111 | | |||
1115 | d->mViewMainPage->setStatusBarVisible(visible); | 1112 | d->mViewMainPage->setStatusBarVisible(visible); | ||
1116 | d->mBrowseMainPage->setStatusBarVisible(visible); | 1113 | d->mBrowseMainPage->setStatusBarVisible(visible); | ||
1117 | } | 1114 | } | ||
1118 | 1115 | | |||
1119 | void MainWindow::updateToggleSideBarAction() | | |||
1120 | { | | |||
1121 | SignalBlocker blocker(d->mToggleSideBarAction); | | |||
1122 | bool visible = d->mSideBar->isVisible(); | | |||
1123 | d->mToggleSideBarAction->setChecked(visible); | | |||
1124 | | ||||
1125 | QString text; | | |||
1126 | if (QApplication::isRightToLeft()) { | | |||
1127 | text = QString::fromUtf8(visible ? "▮→" : "▮←"); | | |||
1128 | } else { | | |||
1129 | text = QString::fromUtf8(visible ? "▮←" : "▮→"); | | |||
1130 | } | | |||
1131 | QString toolTip = visible ? i18nc("@info:tooltip", "Hide sidebar") : i18nc("@info:tooltip", "Show sidebar"); | | |||
1132 | | ||||
1133 | QList<QToolButton*> lst; | | |||
1134 | lst << d->mBrowseMainPage->toggleSideBarButton() | | |||
1135 | << d->mViewMainPage->toggleSideBarButton(); | | |||
1136 | Q_FOREACH(QToolButton * button, lst) { | | |||
1137 | button->setText(text); | | |||
1138 | button->setToolTip(toolTip); | | |||
1139 | } | | |||
1140 | } | | |||
1141 | | ||||
1142 | void MainWindow::slotPartCompleted() | 1116 | void MainWindow::slotPartCompleted() | ||
1143 | { | 1117 | { | ||
1144 | d->updateActions(); | 1118 | d->updateActions(); | ||
1145 | const QUrl url = d->mContextManager->currentUrl(); | 1119 | const QUrl url = d->mContextManager->currentUrl(); | ||
1146 | if (!url.isEmpty()) { | 1120 | if (!url.isEmpty()) { | ||
1147 | d->mFileOpenRecentAction->addUrl(url); | 1121 | d->mFileOpenRecentAction->addUrl(url); | ||
1148 | d->mGvCore->addUrlToRecentFiles(url); | 1122 | d->mGvCore->addUrlToRecentFiles(url); | ||
1149 | } | 1123 | } | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 1262 | { | |||
1289 | if (d->mFullScreenAction->isChecked()) { | 1263 | if (d->mFullScreenAction->isChecked()) { | ||
1290 | d->mFullScreenAction->trigger(); | 1264 | d->mFullScreenAction->trigger(); | ||
1291 | } | 1265 | } | ||
1292 | } | 1266 | } | ||
1293 | 1267 | | |||
1294 | void MainWindow::toggleFullScreen(bool checked) | 1268 | void MainWindow::toggleFullScreen(bool checked) | ||
1295 | { | 1269 | { | ||
1296 | setUpdatesEnabled(false); | 1270 | setUpdatesEnabled(false); | ||
1297 | d->saveSideBarConfig(); | | |||
Your patch solved https://bugs.kde.org/show_bug.cgi?id=389558 too. 👍 rkflx: Your patch solved https://bugs.kde.org/show_bug.cgi?id=389558 too.
👍 | |||||
1298 | if (checked) { | 1271 | if (checked) { | ||
1299 | // Save MainWindow config now, this way if we quit while in | 1272 | // Save MainWindow config now, this way if we quit while in | ||
1300 | // fullscreen, we are sure latest MainWindow changes are remembered. | 1273 | // fullscreen, we are sure latest MainWindow changes are remembered. | ||
1301 | KConfigGroup saveConfigGroup = autoSaveConfigGroup(); | 1274 | KConfigGroup saveConfigGroup = autoSaveConfigGroup(); | ||
1302 | if (!isFullScreen()) { | 1275 | if (!isFullScreen()) { | ||
1303 | // Save state if window manager did not already switch to fullscreen. | 1276 | // Save state if window manager did not already switch to fullscreen. | ||
1304 | saveMainWindowSettings(saveConfigGroup); | 1277 | saveMainWindowSettings(saveConfigGroup); | ||
1305 | d->mStateBeforeFullScreen.mToolBarVisible = toolBar()->isVisible(); | 1278 | d->mStateBeforeFullScreen.mToolBarVisible = toolBar()->isVisible(); | ||
Show All 28 Lines | 1292 | } else { | |||
1334 | d->mFullScreenLeftAt = QDateTime::currentDateTime(); | 1307 | d->mFullScreenLeftAt = QDateTime::currentDateTime(); | ||
1335 | } | 1308 | } | ||
1336 | 1309 | | |||
1337 | d->mFullScreenContent->setFullScreenMode(checked); | 1310 | d->mFullScreenContent->setFullScreenMode(checked); | ||
1338 | d->mBrowseMainPage->setFullScreenMode(checked); | 1311 | d->mBrowseMainPage->setFullScreenMode(checked); | ||
1339 | d->mViewMainPage->setFullScreenMode(checked); | 1312 | d->mViewMainPage->setFullScreenMode(checked); | ||
1340 | d->mSaveBar->setFullScreenMode(checked); | 1313 | d->mSaveBar->setFullScreenMode(checked); | ||
1341 | 1314 | | |||
1342 | d->loadSideBarConfig(); | 1315 | toggleSideBar(d->sideBarVisibility()); | ||
1343 | toggleStatusBar(d->statusBarVisibility()); | 1316 | toggleStatusBar(d->statusBarVisibility()); | ||
1344 | 1317 | | |||
1345 | setUpdatesEnabled(true); | 1318 | setUpdatesEnabled(true); | ||
1346 | d->autoAssignThumbnailProvider(); | 1319 | d->autoAssignThumbnailProvider(); | ||
1347 | } | 1320 | } | ||
1348 | 1321 | | |||
1349 | void MainWindow::saveCurrent() | 1322 | void MainWindow::saveCurrent() | ||
1350 | { | 1323 | { | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 1410 | } else { | |||
1438 | d->mToggleSlideShowAction->setText(i18n("Start Slideshow")); | 1411 | d->mToggleSlideShowAction->setText(i18n("Start Slideshow")); | ||
1439 | d->mToggleSlideShowAction->setIcon(QIcon::fromTheme("media-playback-start")); | 1412 | d->mToggleSlideShowAction->setIcon(QIcon::fromTheme("media-playback-start")); | ||
1440 | } | 1413 | } | ||
1441 | } | 1414 | } | ||
1442 | 1415 | | |||
1443 | bool MainWindow::queryClose() | 1416 | bool MainWindow::queryClose() | ||
1444 | { | 1417 | { | ||
1445 | saveConfig(); | 1418 | saveConfig(); | ||
1446 | d->saveSideBarConfig(); | | |||
1447 | QList<QUrl> list = DocumentFactory::instance()->modifiedDocumentList(); | 1419 | QList<QUrl> list = DocumentFactory::instance()->modifiedDocumentList(); | ||
1448 | if (list.size() == 0) { | 1420 | if (list.size() == 0) { | ||
1449 | return true; | 1421 | return true; | ||
1450 | } | 1422 | } | ||
1451 | 1423 | | |||
1452 | KGuiItem yes(i18n("Save All Changes"), "document-save-all"); | 1424 | KGuiItem yes(i18n("Save All Changes"), "document-save-all"); | ||
1453 | KGuiItem no(i18n("Discard Changes")); | 1425 | KGuiItem no(i18n("Discard Changes")); | ||
1454 | QString msg = i18np("One image has been modified.", "%1 images have been modified.", list.size()) | 1426 | QString msg = i18np("One image has been modified.", "%1 images have been modified.", list.size()) | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 1470 | { | |||
1502 | d->mFileOpenRecentAction->loadEntries(KConfigGroup(KSharedConfig::openConfig(), "Recent Files")); | 1474 | d->mFileOpenRecentAction->loadEntries(KConfigGroup(KSharedConfig::openConfig(), "Recent Files")); | ||
1503 | foreach(const QUrl &url, d->mFileOpenRecentAction->urls()) { | 1475 | foreach(const QUrl &url, d->mFileOpenRecentAction->urls()) { | ||
1504 | d->mGvCore->addUrlToRecentFiles(url); | 1476 | d->mGvCore->addUrlToRecentFiles(url); | ||
1505 | } | 1477 | } | ||
1506 | d->mStartMainPage->loadConfig(); | 1478 | d->mStartMainPage->loadConfig(); | ||
1507 | d->mViewMainPage->loadConfig(); | 1479 | d->mViewMainPage->loadConfig(); | ||
1508 | d->mBrowseMainPage->loadConfig(); | 1480 | d->mBrowseMainPage->loadConfig(); | ||
1509 | d->mContextManager->loadConfig(); | 1481 | d->mContextManager->loadConfig(); | ||
1482 | d->mSideBar->loadConfig(); | ||||
rkflx: Good idea! I think this should stay. | |||||
1510 | } | 1483 | } | ||
1511 | 1484 | | |||
1512 | void MainWindow::saveConfig() | 1485 | void MainWindow::saveConfig() | ||
1513 | { | 1486 | { | ||
1514 | d->mFileOpenRecentAction->saveEntries(KConfigGroup(KSharedConfig::openConfig(), "Recent Files")); | 1487 | d->mFileOpenRecentAction->saveEntries(KConfigGroup(KSharedConfig::openConfig(), "Recent Files")); | ||
1515 | d->mViewMainPage->saveConfig(); | 1488 | d->mViewMainPage->saveConfig(); | ||
1516 | d->mBrowseMainPage->saveConfig(); | 1489 | d->mBrowseMainPage->saveConfig(); | ||
1517 | d->mContextManager->saveConfig(); | 1490 | d->mContextManager->saveConfig(); | ||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |
Using the triggered() signal here (equal to KStandardAction::ShowStatusbar) prevents re-calling the slot from setChecked() inside MainWindow::toggleSideBar() and we don't need the SignalBlocker anymore.