Commit d9069ef6 authored by Andi Sardina Ramos's avatar Andi Sardina Ramos Committed by Albert Astals Cid
Browse files

The shell and the part need to be independent of each other.

This reverts commit 93142598.
parent f2274e89
Pipeline #15176 passed with stage
in 10 minutes and 42 seconds
......@@ -247,7 +247,7 @@ void MainShellTest::testShell()
Okular::Settings::self()->setShellOpenFileInTabs(useTabs);
if (expectPrintDialog || externalProcessExpectPrintDialog) {
const int expectedTab = 0;
const int expectedTab = externalProcessExpectPrintDialog && !unique ? 1 : 0;
helper.reset(new ClosePrintDialogHelper(expectedTab));
QTimer::singleShot(0, helper.data(), SLOT(closePrintDialog()));
}
......@@ -611,14 +611,15 @@ void MainShellTest::testOpenInvalidFiles_data()
QTest::addColumn<QString>("options");
QString options = ShellUtils::serializeOptions( false, false, false, false, false, QString(), QString() );
QUrl validFile = ShellUtils::urlFromArg( QStringLiteral( KDESRCDIR "data/file2.pdf" ), ShellUtils::qfileExistFunc(), QString() );
QUrl validFile1 = ShellUtils::urlFromArg( QStringLiteral( KDESRCDIR "data/file1.pdf" ), ShellUtils::qfileExistFunc(), QString() );
QUrl validFile2 = ShellUtils::urlFromArg( QStringLiteral( KDESRCDIR "data/file2.pdf" ), ShellUtils::qfileExistFunc(), QString() );
QUrl invalidFile = ShellUtils::urlFromArg( QStringLiteral( KDESRCDIR "data/non-existing-doc.pdf" ), ShellUtils::qfileExistFunc(), QString() );
QList<QUrl> firstCase { invalidFile, validFile };
QList<QUrl> secondCase { validFile, invalidFile };
QList<QUrl> firstCase { invalidFile, validFile1, validFile2 };
QList<QUrl> secondCase { validFile1, validFile2, invalidFile };
QTest::newRow( "opening the invalid file first" ) << firstCase << options;
QTest::newRow( "opening the valid file first" ) << secondCase << options;
QTest::newRow( "opening the valids file first" ) << secondCase << options;
}
void MainShellTest::testOpenInvalidFiles()
......@@ -656,9 +657,15 @@ void MainShellTest::testOpenInvalidFiles()
QList<QUrl> recentFiles = shell->m_recent->urls();
QVERIFY( shell->m_tabs.size() == 1 );
QVERIFY( recentFiles.size() == 1 );
QVERIFY( recentFiles.first().toString().contains( QStringLiteral( "data/file2.pdf" ) ) );
QVERIFY( shell->m_tabs.size() == 2 );
QVERIFY( shell->m_tabWidget->tabBar()->isVisible() );
QVERIFY( ! shell->m_tabWidget->tabIcon(0).isNull() );
QVERIFY( ! shell->m_tabWidget->tabIcon(1).isNull() );
QVERIFY( recentFiles.size() == 2 );
}
void MainShellTest::testMiddleButtonCloseUndo()
......
......@@ -673,6 +673,13 @@ void Shell::closeTab( int tab )
void Shell::openNewTab( const QUrl& url, const QString &serializedOptions )
{
// Tabs are hidden when there's only one, so show it
if( m_tabs.size() == 1 )
{
m_tabWidget->tabBar()->show();
m_nextTabAction->setEnabled( true );
m_prevTabAction->setEnabled( true );
}
const int newIndex = m_tabs.size();
......@@ -680,7 +687,10 @@ void Shell::openNewTab( const QUrl& url, const QString &serializedOptions )
m_tabs.append( m_partFactory->create<KParts::ReadWritePart>(this) );
connectPart( m_tabs[newIndex].part );
// Update GUI
KParts::ReadWritePart* const part = m_tabs[newIndex].part;
m_tabWidget->addTab( part->widget(), url.fileName() );
applyOptionsToPart(part, serializedOptions);
int previousActiveTab = m_tabWidget->currentIndex();
......@@ -688,17 +698,6 @@ void Shell::openNewTab( const QUrl& url, const QString &serializedOptions )
if( part->openUrl(url) )
{
// Update GUI
m_tabWidget->addTab( part->widget(), url.fileName() );
// Tabs are hidden when there's only one, so show it
if( m_tabs.size() == 1 )
{
m_tabWidget->tabBar()->show();
m_nextTabAction->setEnabled( true );
m_prevTabAction->setEnabled( true );
}
m_recent->addUrl( url );
}
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment