| 181 | }; |
| 182 | |
| 183 | Shell::Shell(const QString &serializedOptions) |
| 184 | : KParts::MainWindow() |
| 185 | , m_menuBarWasShown(true) |
| 186 | , m_toolBarWasShown(true) |
| 187 | , m_isValid(true) |
| 188 | { |
| 189 | setObjectName(QStringLiteral("okular::Shell#")); |
| 190 | setContextMenuPolicy(Qt::NoContextMenu); |
| 191 | // otherwise .rc file won't be found by unit test |
| 192 | setComponentName(QStringLiteral("okular"), QString()); |
| 193 | // set the shell's ui resource file |
| 194 | setXMLFile(QStringLiteral("shell.rc")); |
| 195 | m_fileformatsscanned = false; |
| 196 | m_showMenuBarAction = nullptr; |
| 197 | // this routine will find and load our Part. it finds the Part by |
| 198 | // name which is a bad idea usually.. but it's alright in this |
| 199 | // case since our Part is made for this Shell |
| 200 | |
| 201 | const auto result = KPluginFactory::loadFactory(KPluginMetaData(QStringLiteral("kf6/parts/okularpart"))); |
| 202 | |
| 203 | if (!result) { |
| 204 | // if we couldn't find our Part, we exit since the Shell by |
| 205 | // itself can't do anything useful |
| 206 | m_isValid = false; |
| 207 | KMessageBox::error(this, i18n("Unable to find the Okular component: %1", result.errorString)); |
| 208 | return; |
| 209 | } else { |
| 210 | m_partFactory = result.plugin; |
| 211 | } |
| 212 | |
| 213 | // now that the Part plugin is loaded, create the part |
| 214 | KParts::ReadWritePart *const firstPart = m_partFactory->create<KParts::ReadWritePart>(this); |
| 215 | if (firstPart) { |
| 216 | // Setup the central widget |
| 217 | m_centralStackedWidget = new ResizableStackedWidget(); |
| 218 | setCentralWidget(m_centralStackedWidget); |
| 219 | |
| 220 | // Setup the welcome screen |
| 221 | m_welcomeScreen = new WelcomeScreen(this); |
| 222 | connect(m_welcomeScreen, &WelcomeScreen::openClicked, this, &Shell::fileOpen); |
| 223 | connect(m_welcomeScreen, &WelcomeScreen::closeClicked, this, &Shell::hideWelcomeScreen); |
| 224 | connect(m_welcomeScreen, &WelcomeScreen::recentItemClicked, this, [this](const QUrl &url) { openUrl(url); }); |
| 225 | connect(m_welcomeScreen, &WelcomeScreen::forgetRecentItem, this, &Shell::forgetRecentItem); |
| 226 | m_centralStackedWidget->addWidget(m_welcomeScreen); |
| 227 | |
| 228 | m_welcomeScreen->installEventFilter(this); |
| 229 | |
| 230 | // Setup tab bar |
| 231 | m_tabWidget = new QTabWidget(this); |
| 232 | m_tabWidget->setTabsClosable(true); |
| 233 | m_tabWidget->setElideMode(Qt::ElideRight); |
| 234 | m_tabWidget->tabBar()->hide(); |
| 235 | m_tabWidget->setDocumentMode(true); |
| 236 | m_tabWidget->setMovable(true); |
| 237 | |
| 238 | m_tabWidget->setAcceptDrops(true); |
| 239 | m_tabWidget->tabBar()->installEventFilter(this); |
| 240 |
nothing calls this directly
no test coverage detected