#include "dolphintabbar.h"
#include "dolphintabpage.h"
#include "dolphinviewcontainer.h"
-#include "dolphin_generalsettings.h"
#include <QApplication>
+#include <QDropEvent>
#include <KConfigGroup>
+#include <KShell>
#include <kio/global.h>
#include <KRun>
QTabWidget(parent),
m_placesSelectorVisible(true)
{
- connect(this, SIGNAL(tabCloseRequested(int)),
- this, SLOT(closeTab(int)));
- connect(this, SIGNAL(currentChanged(int)),
- this, SLOT(currentTabChanged(int)));
+ connect(this, &DolphinTabWidget::tabCloseRequested,
+ this, static_cast<void (DolphinTabWidget::*)(int)>(&DolphinTabWidget::closeTab));
+ connect(this, &DolphinTabWidget::currentChanged,
+ this, &DolphinTabWidget::currentTabChanged);
DolphinTabBar* tabBar = new DolphinTabBar(this);
- connect(tabBar, SIGNAL(openNewActivatedTab(int)),
- this, SLOT(openNewActivatedTab(int)));
- connect(tabBar, SIGNAL(tabDropEvent(int,QDropEvent*)),
- this, SLOT(tabDropEvent(int,QDropEvent*)));
- connect(tabBar, SIGNAL(tabDetachRequested(int)),
- this, SLOT(detachTab(int)));
+ connect(tabBar, &DolphinTabBar::openNewActivatedTab,
+ this, static_cast<void (DolphinTabWidget::*)(int)>(&DolphinTabWidget::openNewActivatedTab));
+ connect(tabBar, &DolphinTabBar::tabDropEvent,
+ this, &DolphinTabWidget::tabDropEvent);
+ connect(tabBar, &DolphinTabBar::tabDetachRequested,
+ this, &DolphinTabWidget::detachTab);
tabBar->hide();
setTabBar(tabBar);
DolphinTabPage* tabPage = new DolphinTabPage(primaryUrl, secondaryUrl, this);
tabPage->setPlacesSelectorVisible(m_placesSelectorVisible);
- connect(tabPage, SIGNAL(activeViewChanged(DolphinViewContainer*)),
- this, SIGNAL(activeViewChanged(DolphinViewContainer*)));
- connect(tabPage, SIGNAL(activeViewUrlChanged(QUrl)),
- this, SLOT(tabUrlChanged(QUrl)));
+ connect(tabPage, &DolphinTabPage::activeViewChanged,
+ this, &DolphinTabWidget::activeViewChanged);
+ connect(tabPage, &DolphinTabPage::activeViewUrlChanged,
+ this, &DolphinTabWidget::tabUrlChanged);
addTab(tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName(primaryUrl));
if (focusWidget) {
}
}
-void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs)
+void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView)
{
- const bool hasSplitView = GeneralSettings::splitView();
+ Q_ASSERT(dirs.size() > 0);
- // Open each directory inside a new tab. If the "split view" option has been enabled,
- // always show two directories within one tab.
QList<QUrl>::const_iterator it = dirs.constBegin();
while (it != dirs.constEnd()) {
const QUrl& primaryUrl = *(it++);
- if (hasSplitView && (it != dirs.constEnd())) {
+ if (splitView && (it != dirs.constEnd())) {
const QUrl& secondaryUrl = *(it++);
openNewTab(primaryUrl, secondaryUrl);
} else {
}
}
-void DolphinTabWidget::openFiles(const QList<QUrl>& files)
+void DolphinTabWidget::openFiles(const QList<QUrl>& files, bool splitView)
{
- if (files.isEmpty()) {
- return;
- }
+ Q_ASSERT(files.size() > 0);
// Get all distinct directories from 'files' and open a tab
// for each directory. If the "split view" option is enabled, two
}
const int oldTabCount = count();
- openDirectories(dirs);
+ openDirectories(dirs, splitView);
const int tabCount = count();
// Select the files. Although the files can be split between several
{
Q_ASSERT(index >= 0);
- const QString separator(QLatin1Char(' '));
- QString command = QLatin1String("dolphin");
+ QStringList args;
const DolphinTabPage* tabPage = tabPageAt(index);
- command += separator + tabPage->primaryViewContainer()->url().url();
+ args << tabPage->primaryViewContainer()->url().url();
if (tabPage->splitViewEnabled()) {
- command += separator + tabPage->secondaryViewContainer()->url().url();
- command += separator + QLatin1String("-split");
+ args << tabPage->secondaryViewContainer()->url().url();
+ args << QStringLiteral("--split");
}
+ const QString command = QStringLiteral("dolphin %1").arg(KShell::joinArgs(args));
KRun::runCommand(command, this);
closeTab(index);
QString DolphinTabWidget::tabName(const QUrl& url) const
{
QString name;
- if (url == QUrl("file:///")) {
+ if (url == QUrl(QStringLiteral("file:///"))) {
name = '/';
} else {
name = url.adjusted(QUrl::StripTrailingSlash).fileName();
} else {
// Make sure that a '&' inside the directory name is displayed correctly
// and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
- name.replace('&', "&&");
+ name.replace('&', QLatin1String("&&"));
}
}
return name;