summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtTabWidget.cpp')
-rw-r--r--Swift/QtUI/QtTabWidget.cpp53
1 files changed, 48 insertions, 5 deletions
diff --git a/Swift/QtUI/QtTabWidget.cpp b/Swift/QtUI/QtTabWidget.cpp
index 614439a..99ef6ee 100644
--- a/Swift/QtUI/QtTabWidget.cpp
+++ b/Swift/QtUI/QtTabWidget.cpp
@@ -1,10 +1,16 @@
/*
- * Copyright (c) 2010 Kevin Smith
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
+ * Copyright (c) 2010-2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
*/
-#include "QtTabWidget.h"
+#include <Swift/QtUI/QtTabWidget.h>
+
+#include <QLabel>
+#include <QPainter>
+#include <QPoint>
+
+#include <Swift/QtUI/Trellis/QtDNDTabBar.h>
namespace Swift {
@@ -17,7 +23,44 @@ QtTabWidget::~QtTabWidget() {
}
QTabBar* QtTabWidget::tabBar() {
- return QTabWidget::tabBar();
+ return QTabWidget::tabBar();
+}
+
+void QtTabWidget::setTabBar(QTabBar* tabBar) {
+ QTabWidget::setTabBar(tabBar);
+ if (dynamic_cast<QtDNDTabBar*>(tabBar)) {
+ setAcceptDrops(true);
+ }
+ else {
+ setAcceptDrops(false);
+ }
+}
+
+void QtTabWidget::dragEnterEvent(QDragEnterEvent* event) {
+ QtDNDTabBar* dndTabBar = dynamic_cast<QtDNDTabBar*>(tabBar());
+ if (dndTabBar) {
+ dndTabBar->dragEnterEvent(event);
+ }
+}
+
+void QtTabWidget::dropEvent(QDropEvent* event) {
+ QtDNDTabBar* dndTabBar = dynamic_cast<QtDNDTabBar*>(tabBar());
+ if (dndTabBar) {
+ dndTabBar->dropEvent(event);
+ }
+}
+
+void QtTabWidget::paintEvent(QPaintEvent * event) {
+ QTabWidget::paintEvent(event);
+ if (count() == 0) {
+ QLabel label;
+ label.setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+ label.setGeometry(QRect(QPoint(0,0), size()) - QMargins(10,10,10,10));
+ label.setWordWrap(true);
+ label.setText(tr("This empty cell is a placeholder for chat windows. You can move existing chats to this cell by dragging the tab over here. You can change the number of cells via the 'Change layout' dialog under the 'View' menu."));
+ QPainter painter(this);
+ painter.drawPixmap(label.geometry().topLeft(), label.grab());
+ }
}
}