Changeset View
Standalone View
shell/shell.cpp
Show All 32 Lines | |||||
33 | #include <KMessageBox> | 33 | #include <KMessageBox> | ||
34 | #include <QMimeType> | 34 | #include <QMimeType> | ||
35 | #include <QMimeDatabase> | 35 | #include <QMimeDatabase> | ||
36 | #include <KStandardAction> | 36 | #include <KStandardAction> | ||
37 | #include <KToolBar> | 37 | #include <KToolBar> | ||
38 | #include <KRecentFilesAction> | 38 | #include <KRecentFilesAction> | ||
39 | #include <KServiceTypeTrader> | 39 | #include <KServiceTypeTrader> | ||
40 | #include <KToggleFullScreenAction> | 40 | #include <KToggleFullScreenAction> | ||
41 | #include <KToggleToolBarAction> | ||||
41 | #include <KActionCollection> | 42 | #include <KActionCollection> | ||
42 | #include <KWindowSystem> | 43 | #include <KWindowSystem> | ||
43 | #include <QTabWidget> | 44 | #include <QTabWidget> | ||
44 | #include <KXMLGUIFactory> | 45 | #include <KXMLGUIFactory> | ||
45 | #include <QDragMoveEvent> | 46 | #include <QDragMoveEvent> | ||
46 | #include <QTabBar> | 47 | #include <QTabBar> | ||
47 | #include <KConfigGroup> | 48 | #include <KConfigGroup> | ||
48 | #include <KUrlMimeData> | 49 | #include <KUrlMimeData> | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 100 | { | |||
115 | setCentralWidget( m_tabWidget ); | 116 | setCentralWidget( m_tabWidget ); | ||
116 | 117 | | |||
117 | // then, setup our actions | 118 | // then, setup our actions | ||
118 | setupActions(); | 119 | setupActions(); | ||
119 | connect( QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &QObject::deleteLater ); | 120 | connect( QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &QObject::deleteLater ); | ||
120 | // and integrate the part's GUI with the shell's | 121 | // and integrate the part's GUI with the shell's | ||
121 | setupGUI(Keys | ToolBar | Save); | 122 | setupGUI(Keys | ToolBar | Save); | ||
122 | createGUI(firstPart); | 123 | createGUI(firstPart); | ||
123 | connectPart( firstPart ); | 124 | configurePart( firstPart ); | ||
124 | 125 | | |||
125 | m_tabs.append( firstPart ); | 126 | m_tabs.append( firstPart ); | ||
126 | m_tabWidget->addTab( firstPart->widget(), QString() ); | 127 | m_tabWidget->addTab( firstPart->widget(), QString() ); | ||
127 | 128 | | |||
128 | readSettings(); | 129 | readSettings(); | ||
129 | 130 | | |||
130 | m_unique = ShellUtils::unique(serializedOptions); | 131 | m_unique = ShellUtils::unique(serializedOptions); | ||
131 | if (m_unique) | 132 | if (m_unique) | ||
▲ Show 20 Lines • Show All 229 Lines • ▼ Show 20 Line(s) | 337 | { | |||
361 | m_prevTabAction->setText( i18n("Previous Tab") ); | 362 | m_prevTabAction->setText( i18n("Previous Tab") ); | ||
362 | actionCollection()->setDefaultShortcuts(m_prevTabAction, KStandardShortcut::tabPrev()); | 363 | actionCollection()->setDefaultShortcuts(m_prevTabAction, KStandardShortcut::tabPrev()); | ||
363 | m_prevTabAction->setEnabled( false ); | 364 | m_prevTabAction->setEnabled( false ); | ||
364 | connect( m_prevTabAction, &QAction::triggered, this, &Shell::activatePrevTab ); | 365 | connect( m_prevTabAction, &QAction::triggered, this, &Shell::activatePrevTab ); | ||
365 | } | 366 | } | ||
366 | 367 | | |||
367 | void Shell::saveProperties(KConfigGroup &group) | 368 | void Shell::saveProperties(KConfigGroup &group) | ||
368 | { | 369 | { | ||
369 | if ( !m_isValid ) // part couldn't be loaded, nothing to save | 370 | if ( !m_isValid ) // part couldn't be loaded, nothing to save | ||
davidhurka: I remember you had struggle to find the annotation toolbar when you tried to show and hide it. | |||||
That’s what I thought about. :) davidhurka: >> @simgunz just wrote:
> https://phabricator.kde.org/D15580#544534
That’s what I thought… | |||||
Initially I put that action in part.rc, while now I moved it to shell.rc. This makes more sense given that the toolbar belongs to the main window somehow owns the toolbars and I create this action in Shell::setupActions() that makes more sense. The problem is that setupActions is called before setupGUI and createGUI so the toolbar does not exist yet. To solve this I have to call toolBar( "mainToolBar" ); to force the creation of the toolbar and so be able to "bind" the KToggleToolBarAction to an existing toolbar. simgunz: Initially I put that action in `part.rc`, while now I moved it to `shell.rc`. This makes more… | |||||
This (maybe) causes one problem now. The default is to open new documents in new windows. Open a new document with the Open action of an existing shell, so a new Okular window appears. Open the annotation toolbar in both windows. Click Hide in the second window. -> Only the annotation toolbar in the first window is closed. davidhurka: This (maybe) causes one problem now. The default is to open new documents in new windows.
Open… | |||||
Good that you spotted this bug, though it is unrelated to this change (I think). If you use Tools → Annotations or the shortcut F6 everything is working correctly. The problem is only related to the Hide buttton in the toolbar. I indeed expected some weird behavior somewhere. simgunz: Good that you spotted this bug, though it is unrelated to this change (I think). If you use… | |||||
davidhurka: Might it be a hint that there are too many toolbars? I think only the part should have the… | |||||
370 | return; | 371 | return; | ||
371 | 372 | | |||
372 | // Gather lists of settings to preserve | 373 | // Gather lists of settings to preserve | ||
373 | QStringList urls; | 374 | QStringList urls; | ||
374 | for( int i = 0; i < m_tabs.size(); ++i ) | 375 | for( int i = 0; i < m_tabs.size(); ++i ) | ||
375 | { | 376 | { | ||
376 | urls.append( m_tabs[i].part->url().url() ); | 377 | urls.append( m_tabs[i].part->url().url() ); | ||
377 | } | 378 | } | ||
▲ Show 20 Lines • Show All 278 Lines • ▼ Show 20 Line(s) | 655 | { | |||
656 | m_nextTabAction->setEnabled( true ); | 657 | m_nextTabAction->setEnabled( true ); | ||
657 | m_prevTabAction->setEnabled( true ); | 658 | m_prevTabAction->setEnabled( true ); | ||
658 | } | 659 | } | ||
659 | 660 | | |||
660 | const int newIndex = m_tabs.size(); | 661 | const int newIndex = m_tabs.size(); | ||
661 | 662 | | |||
662 | // Make new part | 663 | // Make new part | ||
663 | m_tabs.append( m_partFactory->create<KParts::ReadWritePart>(this) ); | 664 | m_tabs.append( m_partFactory->create<KParts::ReadWritePart>(this) ); | ||
664 | connectPart( m_tabs[newIndex].part ); | 665 | configurePart( m_tabs[newIndex].part ); | ||
665 | 666 | | |||
666 | // Update GUI | 667 | // Update GUI | ||
667 | KParts::ReadWritePart* const part = m_tabs[newIndex].part; | 668 | KParts::ReadWritePart* const part = m_tabs[newIndex].part; | ||
668 | m_tabWidget->addTab( part->widget(), url.fileName() ); | 669 | m_tabWidget->addTab( part->widget(), url.fileName() ); | ||
669 | 670 | | |||
670 | applyOptionsToPart(part, serializedOptions); | 671 | applyOptionsToPart(part, serializedOptions); | ||
671 | 672 | | |||
672 | int previousActiveTab = m_tabWidget->currentIndex(); | 673 | int previousActiveTab = m_tabWidget->currentIndex(); | ||
Show All 14 Lines | 683 | { | |||
687 | if ( ShellUtils::showPrintDialog(serializedOptions) ) | 688 | if ( ShellUtils::showPrintDialog(serializedOptions) ) | ||
688 | QMetaObject::invokeMethod( part, "enableStartWithPrint" ); | 689 | QMetaObject::invokeMethod( part, "enableStartWithPrint" ); | ||
689 | if ( ShellUtils::showPrintDialogAndExit(serializedOptions) ) | 690 | if ( ShellUtils::showPrintDialogAndExit(serializedOptions) ) | ||
690 | QMetaObject::invokeMethod( part, "enableExitAfterPrint" ); | 691 | QMetaObject::invokeMethod( part, "enableExitAfterPrint" ); | ||
691 | if(!find.isEmpty()) | 692 | if(!find.isEmpty()) | ||
692 | QMetaObject::invokeMethod( part, "enableStartWithFind", Q_ARG( const QString &, find )); | 693 | QMetaObject::invokeMethod( part, "enableStartWithFind", Q_ARG( const QString &, find )); | ||
693 | } | 694 | } | ||
694 | 695 | | |||
695 | void Shell::connectPart( QObject* part ) | 696 | void Shell::configurePart( KParts::ReadWritePart* part ) | ||
696 | { | 697 | { | ||
697 | connect( this, SIGNAL(moveSplitter(int)), part, SLOT(moveSplitter(int)) ); | 698 | connect( this, SIGNAL(moveSplitter(int)), part, SLOT(moveSplitter(int)) ); | ||
698 | connect( part, SIGNAL(enablePrintAction(bool)), this, SLOT(setPrintEnabled(bool))); | 699 | connect( part, SIGNAL(enablePrintAction(bool)), this, SLOT(setPrintEnabled(bool))); | ||
699 | connect( part, SIGNAL(enableCloseAction(bool)), this, SLOT(setCloseEnabled(bool))); | 700 | connect( part, SIGNAL(enableCloseAction(bool)), this, SLOT(setCloseEnabled(bool))); | ||
700 | connect( part, SIGNAL(mimeTypeChanged(QMimeType)), this, SLOT(setTabIcon(QMimeType))); | 701 | connect( part, SIGNAL(mimeTypeChanged(QMimeType)), this, SLOT(setTabIcon(QMimeType))); | ||
701 | connect( part, SIGNAL(urlsDropped(QList<QUrl>)), this, SLOT(handleDroppedUrls(QList<QUrl>)) ); | 702 | connect( part, SIGNAL(urlsDropped(QList<QUrl>)), this, SLOT(handleDroppedUrls(QList<QUrl>)) ); | ||
702 | connect( part, SIGNAL(fitWindowToPage(QSize,QSize)), this, SLOT(slotFitWindowToPage(QSize,QSize)) ); | 703 | connect( part, SIGNAL(fitWindowToPage(QSize,QSize)), this, SLOT(slotFitWindowToPage(QSize,QSize)) ); | ||
704 | | ||||
705 | KToggleToolBarAction * aToggleAnnotator = new KToggleToolBarAction( toolBar("annotationToolBar"), i18n("&Review"), this ); | ||||
706 | aToggleAnnotator->setIcon( QIcon::fromTheme( QStringLiteral("draw-freehand") ) ); | ||||
707 | part->actionCollection()->addAction( QStringLiteral("mouse_toggle_annotate"), aToggleAnnotator ); | ||||
708 | part->actionCollection()->setDefaultShortcut( aToggleAnnotator, Qt::Key_F6 ); | ||||
703 | } | 709 | } | ||
704 | 710 | | |||
705 | void Shell::print() | 711 | void Shell::print() | ||
706 | { | 712 | { | ||
707 | QMetaObject::invokeMethod( m_tabs[m_tabWidget->currentIndex()].part, "slotPrint" ); | 713 | QMetaObject::invokeMethod( m_tabs[m_tabWidget->currentIndex()].part, "slotPrint" ); | ||
708 | } | 714 | } | ||
709 | 715 | | |||
710 | void Shell::setPrintEnabled( bool enabled ) | 716 | void Shell::setPrintEnabled( bool enabled ) | ||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |
I remember you had struggle to find the annotation toolbar when you tried to show and hide it. Is this code related to the problem and did you solve the problem?