diff options
author | Tobias Markmann <tm@ayena.de> | 2014-11-25 14:07:29 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2014-12-14 14:44:00 (GMT) |
commit | b4a54583c4d575fe152122c21da616c3c942bbfd (patch) | |
tree | 7e558fd9cb75291f4d5eec90da9d8dd5650ceea2 /Swift/QtUI/Trellis/QtDynamicGridLayout.h | |
parent | 92672e17a52d0c86e693183627c8c6b8fa44fb86 (diff) | |
download | swift-b4a54583c4d575fe152122c21da616c3c942bbfd.zip swift-b4a54583c4d575fe152122c21da616c3c942bbfd.tar.bz2 |
Add support for new trellis layout for chat windows.
This includes dynamic customizable grid layouting of chat tabs including:
- arrengement of tabs via menu, keyboard shortcuts or drag'n'drop
- change of grid size via mouse or keyboard
- save/restore of grid size and positions of chats inside the grid
Test-Information:
Tested on OS X 10.9.8.
Change-Id: I43f94293a1c672971640c3000abfc6530f2ea7a8
Diffstat (limited to 'Swift/QtUI/Trellis/QtDynamicGridLayout.h')
-rw-r--r-- | Swift/QtUI/Trellis/QtDynamicGridLayout.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Swift/QtUI/Trellis/QtDynamicGridLayout.h b/Swift/QtUI/Trellis/QtDynamicGridLayout.h new file mode 100644 index 0000000..c87dc21 --- /dev/null +++ b/Swift/QtUI/Trellis/QtDynamicGridLayout.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014 Kevin Smith and Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <QGridLayout> +#include <QHash> +#include <QPoint> +#include <QSize> +#include <QString> +#include <QWidget> + +namespace Swift { + class QtTabbable; + class QtTabWidget; + + class QtDynamicGridLayout : public QWidget { + Q_OBJECT + public: + explicit QtDynamicGridLayout(QWidget* parent = 0, bool enableDND = false); + virtual ~QtDynamicGridLayout(); + + QSize getDimension() const; + + // emulate QtTabWidget API + int addTab(QtTabbable* tab, const QString& title); + void removeTab(int index); + int count() const; + + QWidget* widget(int index) const; + QWidget* currentWidget() const; + void setCurrentWidget(QWidget* widget); + + QtTabWidget* indexToTabWidget(int index, int& tabIndex); + + int indexOf(const QWidget* widget) const; + int currentIndex() const; + void setCurrentIndex(int index); + + bool isDNDEnabled() const; + + QHash<QString, QPoint> getTabPositions() const; + void setTabPositions(const QHash<QString, QPoint> positions); + + signals: + void tabCloseRequested(int index); + + public slots: + void setDimensions(const QSize& dim); + + // Tab Management + void moveCurrentTabRight(); + void moveCurrentTabLeft(); + void moveCurrentTabToNextGroup(); + void moveCurrentTabToPreviousGroup(); + + void updateTabPositions(); + + private slots: + void handleTabCloseRequested(int index); + + private: + void moveTab(QtTabWidget* tabWidget, int oldIndex, int newIndex); + QtTabWidget* createDNDTabWidget(QWidget* parent); + + private: + QGridLayout *gridLayout_; + bool dndEnabled_; + QHash<QString, QPoint> tabPositions_; + }; +} |