summaryrefslogtreecommitdiffstats
path: root/kicker/taskbar
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-04-12 16:49:43 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-04-12 16:49:43 -0500
commit18098b4c7042e7ce2f965964bb8977b4f17b9842 (patch)
tree5208af2813df58ff9ef7d5c878a516bd54c368d9 /kicker/taskbar
parentb28da13a4da674958eea60d6be6594766e42c757 (diff)
downloadtdebase-18098b4c7042e7ce2f965964bb8977b4f17b9842.tar.gz
tdebase-18098b4c7042e7ce2f965964bb8977b4f17b9842.zip
Add initial taskbar drag and drop support
This partially resolves Bug 1103 Save horizontal space around TDE Menu button when text is in use and Kicker is greater than one line in height
Diffstat (limited to 'kicker/taskbar')
-rw-r--r--kicker/taskbar/taskbar.cpp69
-rw-r--r--kicker/taskbar/taskbar.h2
-rw-r--r--kicker/taskbar/taskbar.kcfg5
-rw-r--r--kicker/taskbar/taskbarcontainer.cpp41
-rw-r--r--kicker/taskbar/taskbarcontainer.h5
-rw-r--r--kicker/taskbar/taskcontainer.cpp32
-rw-r--r--kicker/taskbar/taskcontainer.h7
7 files changed, 157 insertions, 4 deletions
diff --git a/kicker/taskbar/taskbar.cpp b/kicker/taskbar/taskbar.cpp
index 1e27050f3..40cc04fe1 100644
--- a/kicker/taskbar/taskbar.cpp
+++ b/kicker/taskbar/taskbar.cpp
@@ -1295,3 +1295,72 @@ void TaskBar::sortContainersByDesktop(TaskContainer::List& list)
}
}
+int TaskBar::taskMoveHandler(const TQPoint &pos, Task::List taskList) {
+ TaskContainer* movingContainer = NULL;
+ TaskContainer* destContainer = NULL;
+ bool movingRight = true;
+
+ TaskContainer::Iterator it = containers.begin();
+ for (; it != containers.end(); ++it)
+ {
+ TaskContainer* c = *it;
+ if (c->taskList() == taskList) {
+ movingContainer = c;
+ break;
+ }
+ }
+
+ if (movingContainer) {
+ // Find the best place for the container to go...
+ it = containers.begin();
+ for (; it != containers.end(); ++it)
+ {
+ TaskContainer* c = *it;
+ TQPoint containerPos = c->pos();
+ TQSize containerSize = c->size();
+ TQRect containerRect(containerPos.x(), containerPos.y(), containerSize.width(), containerSize.height());
+ if (containerRect.contains(pos)) {
+ destContainer = c;
+ // Figure out if the mobile container is moving towards the end of the container list (i.e. right or down)
+ for (; it != containers.end(); ++it)
+ {
+ if (movingContainer == (*it)) {
+ movingRight = false;
+ }
+ }
+ break;
+ }
+ }
+
+ if (destContainer == movingContainer) {
+ return false;
+ }
+
+ removeChild(movingContainer);
+ containers.remove(movingContainer);
+
+ if (destContainer) {
+ it = containers.find(destContainer);
+ if ((it != containers.end()) && (movingRight)) {
+ it++;
+ }
+ if (it != containers.end()) {
+ containers.insert(it, movingContainer);
+ }
+ else {
+ containers.append(movingContainer);
+ }
+ }
+ else {
+ containers.append(movingContainer);
+ }
+
+ addChild(movingContainer);
+ reLayoutEventually();
+ emit containerCountChanged();
+
+ return true;
+ }
+
+ return false;
+} \ No newline at end of file
diff --git a/kicker/taskbar/taskbar.h b/kicker/taskbar/taskbar.h
index afb59c365..f12ee895d 100644
--- a/kicker/taskbar/taskbar.h
+++ b/kicker/taskbar/taskbar.h
@@ -65,6 +65,8 @@ public:
KTextShadowEngine *textShadowEngine();
+ int taskMoveHandler(const TQPoint &pos, Task::List taskList);
+
public slots:
void configure();
void setBackground();
diff --git a/kicker/taskbar/taskbar.kcfg b/kicker/taskbar/taskbar.kcfg
index b87c32eaf..320b8a2d6 100644
--- a/kicker/taskbar/taskbar.kcfg
+++ b/kicker/taskbar/taskbar.kcfg
@@ -11,6 +11,11 @@
<label>Use the global taskbar configuration</label>
<whatsthis>Turning this option off will cause the taskbar to ignore the global taskbar configuration, instead using a specific configuration for that particular taskbar.</whatsthis>
</entry>
+ <entry key="AllowDragAndDropReArrange" type="Bool" >
+ <default>true</default>
+ <label>Allow taskbar items to be rearranged using drag and drop</label>
+ <whatsthis>Turning this option on will allow tasks on the taskbar to be manually rearranged using drag and drop.</whatsthis>
+ </entry>
<entry key="ShowAllWindows" type="Bool" >
<default>true</default>
<label>Show windows from all desktops</label>
diff --git a/kicker/taskbar/taskbarcontainer.cpp b/kicker/taskbar/taskbarcontainer.cpp
index 5a75f7c15..030a565dc 100644
--- a/kicker/taskbar/taskbarcontainer.cpp
+++ b/kicker/taskbar/taskbarcontainer.cpp
@@ -74,6 +74,8 @@ TaskBarContainer::TaskBarContainer( bool enableFrame, TQString configFileOverrid
settingsObject = new TaskBarSettings(TDESharedConfig::openConfig(configFile));
globalSettingsObject = new TaskBarSettings(TDESharedConfig::openConfig(GLOBAL_TASKBAR_CONFIG_FILE_NAME));
+ setAcceptDrops(true); // Always enabled to activate task during drag&drop.
+
setBackgroundOrigin( AncestorOrigin );
uint margin;
@@ -327,3 +329,42 @@ void TaskBarContainer::setBackground()
{
taskBar->setBackground();
}
+
+void TaskBarContainer::dragEnterEvent( TQDragEnterEvent* e )
+{
+ // ignore all drags other than tasks
+ if (!TaskDrag::canDecode(e))
+ {
+ return;
+ }
+
+ if (TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange))
+ {
+ if (!READ_MERGED_TASBKAR_SETTING(sortByApp)) {
+ e->accept();
+ }
+ }
+}
+
+void TaskBarContainer::dragLeaveEvent( TQDragLeaveEvent* e )
+{
+ TQFrame::dragLeaveEvent( e );
+}
+
+void TaskBarContainer::dropEvent( TQDropEvent* e )
+{
+ // ignore all drags other than tasks
+ if (!TaskDrag::canDecode(e))
+ {
+ return;
+ }
+
+ if (TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange))
+ {
+ if (!READ_MERGED_TASBKAR_SETTING(sortByApp)) {
+ if (taskBar->taskMoveHandler(taskBar->mapFrom(this, e->pos()), TaskDrag::decode(e))) {
+ e->accept();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/kicker/taskbar/taskbarcontainer.h b/kicker/taskbar/taskbarcontainer.h
index fb5f26dd1..7fc13241f 100644
--- a/kicker/taskbar/taskbarcontainer.h
+++ b/kicker/taskbar/taskbarcontainer.h
@@ -52,6 +52,11 @@ public:
TQSize sizeHint( KPanelExtension::Position, TQSize maxSize ) const;
void setBackground();
+protected:
+ void dragEnterEvent(TQDragEnterEvent*);
+ void dragLeaveEvent(TQDragLeaveEvent*);
+ void dropEvent(TQDropEvent*);
+
k_dcop:
void configChanged();
diff --git a/kicker/taskbar/taskcontainer.cpp b/kicker/taskbar/taskcontainer.cpp
index d63166bb8..484a85659 100644
--- a/kicker/taskbar/taskcontainer.cpp
+++ b/kicker/taskbar/taskcontainer.cpp
@@ -1393,12 +1393,19 @@ void TaskContainer::publishIconGeometry( TQPoint global )
void TaskContainer::dragEnterEvent( TQDragEnterEvent* e )
{
- // ignore task drags and applet drags
- if (TaskDrag::canDecode(e) || PanelDrag::canDecode(e))
+ // ignore applet drags
+ if (PanelDrag::canDecode(e))
{
return;
}
+ if (TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange))
+ {
+ if (!READ_MERGED_TASBKAR_SETTING(sortByApp)) {
+ e->accept();
+ }
+ }
+
// if a dragitem is held for over a taskbutton for two seconds,
// activate corresponding window
if (m_filteredTasks.isEmpty())
@@ -1415,6 +1422,27 @@ void TaskContainer::dragEnterEvent( TQDragEnterEvent* e )
TQToolButton::dragEnterEvent( e );
}
+void TaskContainer::dropEvent( TQDropEvent* e )
+{
+ // Ignore all drops except tasks
+ if (!TaskDrag::canDecode(e)) {
+ return;
+ }
+
+ if (TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange))
+ {
+ if (!READ_MERGED_TASBKAR_SETTING(sortByApp)) {
+ if (taskBar->taskMoveHandler(TQWidget::mapTo(taskBar, e->pos()), TaskDrag::decode(e))) {
+ e->accept();
+ }
+ }
+ }
+
+ dragSwitchTimer.stop();
+
+ TQToolButton::dropEvent( e );
+}
+
void TaskContainer::dragLeaveEvent( TQDragLeaveEvent* e )
{
dragSwitchTimer.stop();
diff --git a/kicker/taskbar/taskcontainer.h b/kicker/taskbar/taskcontainer.h
index b7016477e..857cd6c45 100644
--- a/kicker/taskbar/taskcontainer.h
+++ b/kicker/taskbar/taskcontainer.h
@@ -87,9 +87,11 @@ public:
void updateKickerTip(KickerTip::Data&);
void finish();
-
+
void setBackground();
-
+
+ Task::List taskList() const { return tasks; }
+
public slots:
void updateNow();
@@ -105,6 +107,7 @@ protected:
void mouseMoveEvent(TQMouseEvent*);
void dragEnterEvent(TQDragEnterEvent*);
void dragLeaveEvent(TQDragLeaveEvent*);
+ void dropEvent(TQDropEvent*);
void enterEvent(TQEvent*);
void leaveEvent(TQEvent*);
bool startDrag(const TQPoint& pos);