Changeset View
Changeset View
Standalone View
Standalone View
src/dolphintabbar.cpp
Show All 14 Lines | |||||
15 | * along with this program; if not, write to the * | 15 | * along with this program; if not, write to the * | ||
16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | #include "dolphintabbar.h" | 20 | #include "dolphintabbar.h" | ||
21 | 21 | | |||
22 | #include <KLocalizedString> | 22 | #include <KLocalizedString> | ||
23 | #include <KNameAndUrlInputDialog> | ||||
elvisangelaccio: Unused, please remove it. | |||||
23 | 24 | | |||
24 | #include <QDragEnterEvent> | 25 | #include <QDragEnterEvent> | ||
25 | #include <QMenu> | 26 | #include <QMenu> | ||
26 | #include <QMimeData> | 27 | #include <QMimeData> | ||
27 | #include <QTimer> | 28 | #include <QTimer> | ||
29 | #include <QPointer> | ||||
30 | #include <QInputDialog> | ||||
28 | 31 | | |||
29 | DolphinTabBar::DolphinTabBar(QWidget* parent) : | 32 | DolphinTabBar::DolphinTabBar(QWidget* parent) : | ||
30 | QTabBar(parent), | 33 | QTabBar(parent), | ||
31 | m_autoActivationIndex(-1), | 34 | m_autoActivationIndex(-1), | ||
32 | m_tabToBeClosedOnMiddleMouseButtonRelease(-1) | 35 | m_tabToBeClosedOnMiddleMouseButtonRelease(-1) | ||
33 | { | 36 | { | ||
34 | setAcceptDrops(true); | 37 | setAcceptDrops(true); | ||
35 | setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); | 38 | setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); | ||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | |||||
133 | void DolphinTabBar::contextMenuEvent(QContextMenuEvent* event) | 136 | void DolphinTabBar::contextMenuEvent(QContextMenuEvent* event) | ||
134 | { | 137 | { | ||
135 | const int index = tabAt(event->pos()); | 138 | const int index = tabAt(event->pos()); | ||
136 | 139 | | |||
137 | if (index >= 0) { | 140 | if (index >= 0) { | ||
138 | // Tab context menu | 141 | // Tab context menu | ||
139 | QMenu menu(this); | 142 | QMenu menu(this); | ||
140 | 143 | | |||
144 | QAction* renameTabAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-rename")), i18nc("@action:inmenu", "Rename Tab")); | ||||
141 | QAction* newTabAction = menu.addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@action:inmenu", "New Tab")); | 145 | QAction* newTabAction = menu.addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@action:inmenu", "New Tab")); | ||
142 | QAction* detachTabAction = menu.addAction(QIcon::fromTheme(QStringLiteral("tab-detach")), i18nc("@action:inmenu", "Detach Tab")); | 146 | QAction* detachTabAction = menu.addAction(QIcon::fromTheme(QStringLiteral("tab-detach")), i18nc("@action:inmenu", "Detach Tab")); | ||
143 | QAction* closeOtherTabsAction = menu.addAction(QIcon::fromTheme(QStringLiteral("tab-close-other")), i18nc("@action:inmenu", "Close Other Tabs")); | 147 | QAction* closeOtherTabsAction = menu.addAction(QIcon::fromTheme(QStringLiteral("tab-close-other")), i18nc("@action:inmenu", "Close Other Tabs")); | ||
144 | QAction* closeTabAction = menu.addAction(QIcon::fromTheme(QStringLiteral("tab-close")), i18nc("@action:inmenu", "Close Tab")); | 148 | QAction* closeTabAction = menu.addAction(QIcon::fromTheme(QStringLiteral("tab-close")), i18nc("@action:inmenu", "Close Tab")); | ||
145 | 149 | | |||
146 | QAction* selectedAction = menu.exec(event->globalPos()); | 150 | QAction* selectedAction = menu.exec(event->globalPos()); | ||
147 | if (selectedAction == newTabAction) { | 151 | if (selectedAction == newTabAction) { | ||
148 | emit openNewActivatedTab(index); | 152 | emit openNewActivatedTab(index); | ||
149 | } else if (selectedAction == detachTabAction) { | 153 | } else if (selectedAction == detachTabAction) { | ||
150 | emit tabDetachRequested(index); | 154 | emit tabDetachRequested(index); | ||
151 | } else if (selectedAction == closeOtherTabsAction) { | 155 | } else if (selectedAction == closeOtherTabsAction) { | ||
152 | const int tabCount = count(); | 156 | const int tabCount = count(); | ||
153 | for (int i = 0; i < index; i++) { | 157 | for (int i = 0; i < index; i++) { | ||
154 | emit tabCloseRequested(0); | 158 | emit tabCloseRequested(0); | ||
155 | } | 159 | } | ||
156 | for (int i = index + 1; i < tabCount; i++) { | 160 | for (int i = index + 1; i < tabCount; i++) { | ||
157 | emit tabCloseRequested(1); | 161 | emit tabCloseRequested(1); | ||
158 | } | 162 | } | ||
159 | } else if (selectedAction == closeTabAction) { | 163 | } else if (selectedAction == closeTabAction) { | ||
160 | emit tabCloseRequested(index); | 164 | emit tabCloseRequested(index); | ||
165 | } else if (selectedAction == renameTabAction) { | ||||
166 | bool result = false; | ||||
ngraham: Spaces around the equals sign | |||||
We could use a more descriptive variable name here, for example renamed or similar. elvisangelaccio: We could use a more descriptive variable name here, for example `renamed` or similar. | |||||
167 | QString newTabName = QInputDialog::getText(this, | ||||
elvisangelaccio: Please add `const` | |||||
168 | i18n("Rename Tab"), i18n("New tab name"), QLineEdit::Normal, tabText(index), &result | ||||
ngraham: "Rename Tab" (use title case for window titles) | |||||
elvisangelaccio: Maybe we can add a colon at the end of "New tab name" ? | |||||
169 | ); | ||||
170 | if (result) { | ||||
171 | emit tabRenamed(index, newTabName); | ||||
172 | } | ||||
161 | } | 173 | } | ||
162 | 174 | | |||
163 | return; | 175 | return; | ||
164 | } | 176 | } | ||
165 | 177 | | |||
166 | QTabBar::contextMenuEvent(event); | 178 | QTabBar::contextMenuEvent(event); | ||
167 | } | 179 | } | ||
168 | 180 | | |||
Show All 20 Lines |
Unused, please remove it.