summaryrefslogtreecommitdiffstats
path: root/kicker
diff options
context:
space:
mode:
Diffstat (limited to 'kicker')
-rw-r--r--kicker/taskbar/taskbar.cpp153
-rw-r--r--kicker/taskbar/taskbar.h31
-rw-r--r--kicker/taskbar/taskbarcontainer.cpp14
-rw-r--r--kicker/taskbar/taskcontainer.cpp68
-rw-r--r--kicker/taskbar/taskcontainer.h22
-rw-r--r--kicker/taskmanager/taskrmbmenu.cpp11
-rw-r--r--kicker/taskmanager/taskrmbmenu.h3
7 files changed, 254 insertions, 48 deletions
diff --git a/kicker/taskbar/taskbar.cpp b/kicker/taskbar/taskbar.cpp
index 40cc04fe1..ad68f1c8f 100644
--- a/kicker/taskbar/taskbar.cpp
+++ b/kicker/taskbar/taskbar.cpp
@@ -1295,7 +1295,46 @@ void TaskBar::sortContainersByDesktop(TaskContainer::List& list)
}
}
-int TaskBar::taskMoveHandler(const TQPoint &pos, Task::List taskList) {
+TaskMoveDestination::TaskMoveDestination TaskBar::taskMoveCapabilities(TaskContainer* movingContainer) {
+ TaskMoveDestination::TaskMoveDestination ret = TaskMoveDestination::Null;
+
+ bool before = false;
+ bool after = false;
+ bool movingFound = false;
+
+ if (movingContainer) {
+ // Check to see if there are any visible containers before or after the movingContainer
+ TaskContainer::Iterator it = containers.begin();
+ for (; it != containers.end(); ++it)
+ {
+ TaskContainer* c = *it;
+ if (!c->isVisibleTo(this)) {
+ continue;
+ }
+ if (c == movingContainer) {
+ movingFound = true;
+ }
+ else {
+ if (movingFound) {
+ after = true;
+ }
+ else {
+ before = true;
+ }
+ }
+ }
+ if (before) {
+ ret = ret | TaskMoveDestination::Left;
+ }
+ if (after) {
+ ret = ret | TaskMoveDestination::Right;
+ }
+ }
+
+ return ret;
+}
+
+int TaskBar::taskMoveHandler(TaskMoveDestination::TaskMoveDestination dest, Task::List taskList, const TQPoint pos) {
TaskContainer* movingContainer = NULL;
TaskContainer* destContainer = NULL;
bool movingRight = true;
@@ -1304,6 +1343,9 @@ int TaskBar::taskMoveHandler(const TQPoint &pos, Task::List taskList) {
for (; it != containers.end(); ++it)
{
TaskContainer* c = *it;
+ if (!c->isVisibleTo(this)) {
+ continue;
+ }
if (c->taskList() == taskList) {
movingContainer = c;
break;
@@ -1311,26 +1353,98 @@ int TaskBar::taskMoveHandler(const TQPoint &pos, Task::List taskList) {
}
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;
+ if (dest == TaskMoveDestination::Position) {
+ // Find the best place for the container to go...
+ it = containers.begin();
+ for (; it != containers.end(); ++it)
+ {
+ TaskContainer* c = *it;
+ if (!c->isVisibleTo(this)) {
+ continue;
+ }
+ 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;
}
- break;
}
}
+ else if (dest == TaskMoveDestination::Beginning) {
+ // Move to beginning
+ it = containers.begin();
+ while ((it != containers.end()) && (!(*it)->isVisibleTo(this))) {
+ it++;
+ }
+ if (it == containers.end()) {
+ return false;
+ }
+ destContainer = *it;
+ movingRight = false;
+ }
+ else if (dest == TaskMoveDestination::Left) {
+ // Move left
+ it = containers.begin();
+ while ((it != containers.end()) && (!(*it)->isVisibleTo(this))) {
+ it++;
+ }
+ if (it == containers.end()) {
+ return false;
+ }
+ TaskContainer* prev = *it;
+ destContainer = prev;
+ for (; it != containers.end(); ++it)
+ {
+ TaskContainer* c = *it;
+ if (!c->isVisibleTo(this)) {
+ continue;
+ }
+ if (movingContainer == c) {
+ destContainer = prev;
+ break;
+ }
+ prev = c;
+ }
+ movingRight = false;
+ }
+ else if (dest == TaskMoveDestination::Right) {
+ // Move right
+ it = containers.begin();
+ destContainer = NULL;
+ for (; it != containers.end(); ++it)
+ {
+ TaskContainer* c = *it;
+ if (!c->isVisibleTo(this)) {
+ continue;
+ }
+ if (movingContainer == c) {
+ if (it != containers.end()) {
+ it++;
+ while ((it != containers.end()) && (!(*it)->isVisibleTo(this))) {
+ it++;
+ }
+ }
+ if ((it != containers.end()) && ((*it)->isVisibleTo(this))) {
+ destContainer = *it;
+ }
+ break;
+ }
+ }
+ movingRight = true;
+ }
+ else if (dest == TaskMoveDestination::End) {
+ // Move to end
+ destContainer = NULL;
+ movingRight = true;
+ }
if (destContainer == movingContainer) {
return false;
@@ -1343,8 +1457,11 @@ int TaskBar::taskMoveHandler(const TQPoint &pos, Task::List taskList) {
it = containers.find(destContainer);
if ((it != containers.end()) && (movingRight)) {
it++;
+ while ((it != containers.end()) && (!(*it)->isVisibleTo(this))) {
+ it++;
+ }
}
- if (it != containers.end()) {
+ if ((it != containers.end()) && ((*it)->isVisibleTo(this))) {
containers.insert(it, movingContainer);
}
else {
diff --git a/kicker/taskbar/taskbar.h b/kicker/taskbar/taskbar.h
index f12ee895d..8c1c42e93 100644
--- a/kicker/taskbar/taskbar.h
+++ b/kicker/taskbar/taskbar.h
@@ -39,6 +39,34 @@ class Startup;
class Task;
class TDEGlobalAccel;
+namespace TaskMoveDestination
+{
+ enum TaskMoveDestination
+ {
+ Null = 0x00,
+ Position = 0x01,
+ Left = 0x02,
+ Right = 0x04,
+ Beginning = 0x08,
+ End = 0x10
+ };
+
+ inline TaskMoveDestination operator|(TaskMoveDestination a, TaskMoveDestination b)
+ {
+ return static_cast<TaskMoveDestination>(static_cast<int>(a) | static_cast<int>(b));
+ }
+
+ inline TaskMoveDestination operator&(TaskMoveDestination a, TaskMoveDestination b)
+ {
+ return static_cast<TaskMoveDestination>(static_cast<int>(a) & static_cast<int>(b));
+ }
+
+ inline TaskMoveDestination operator~(TaskMoveDestination a)
+ {
+ return static_cast<TaskMoveDestination>(~static_cast<int>(a));
+ }
+};
+
class TaskBar : public Panner
{
Q_OBJECT
@@ -65,7 +93,8 @@ public:
KTextShadowEngine *textShadowEngine();
- int taskMoveHandler(const TQPoint &pos, Task::List taskList);
+ int taskMoveHandler(TaskMoveDestination::TaskMoveDestination dest, Task::List taskList, const TQPoint pos = TQPoint(0,0));
+ TaskMoveDestination::TaskMoveDestination taskMoveCapabilities(TaskContainer* movingContainer);
public slots:
void configure();
diff --git a/kicker/taskbar/taskbarcontainer.cpp b/kicker/taskbar/taskbarcontainer.cpp
index 030a565dc..fa105de15 100644
--- a/kicker/taskbar/taskbarcontainer.cpp
+++ b/kicker/taskbar/taskbarcontainer.cpp
@@ -338,11 +338,9 @@ void TaskBarContainer::dragEnterEvent( TQDragEnterEvent* e )
return;
}
- if (TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange))
+ if ((e->source()->parent() == taskBar->viewport()) && TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange) && (!READ_MERGED_TASBKAR_SETTING(sortByApp)))
{
- if (!READ_MERGED_TASBKAR_SETTING(sortByApp)) {
- e->accept();
- }
+ e->accept();
}
}
@@ -359,12 +357,10 @@ void TaskBarContainer::dropEvent( TQDropEvent* e )
return;
}
- if (TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange))
+ if ((e->source()->parent() == taskBar->viewport()) && TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange) && (!READ_MERGED_TASBKAR_SETTING(sortByApp)))
{
- if (!READ_MERGED_TASBKAR_SETTING(sortByApp)) {
- if (taskBar->taskMoveHandler(taskBar->mapFrom(this, e->pos()), TaskDrag::decode(e))) {
- e->accept();
- }
+ if (taskBar->taskMoveHandler(TaskMoveDestination::Position, TaskDrag::decode(e), taskBar->mapFrom(this, e->pos()))) {
+ e->accept();
}
}
} \ No newline at end of file
diff --git a/kicker/taskbar/taskcontainer.cpp b/kicker/taskbar/taskcontainer.cpp
index 484a85659..d29321382 100644
--- a/kicker/taskbar/taskcontainer.cpp
+++ b/kicker/taskbar/taskcontainer.cpp
@@ -1224,7 +1224,7 @@ void TaskContainer::popupMenu(int action)
return;
}
- m_menu = new TaskRMBMenu(m_filteredTasks, taskBar->showAllWindows());
+ m_menu = new TaskRMBMenu(m_filteredTasks, taskBar->showAllWindows(), (READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange))?makeTaskMoveMenu():NULL);
}
else
{
@@ -1262,6 +1262,58 @@ void TaskContainer::popupMenu(int action)
m_menu = 0;
}
+TQPopupMenu* TaskContainer::makeTaskMoveMenu()
+{
+ TaskMoveDestination::TaskMoveDestination capabilities = taskBar->taskMoveCapabilities(this);
+
+ int id;
+ TQPopupMenu* menu = new TQPopupMenu();
+
+ menu->setCheckable(false);
+
+ id = menu->insertItem(SmallIconSet("start"),
+ i18n("Move to Beginning"),
+ this, TQT_SLOT(slotTaskMoveBeginning()));
+ menu->setItemEnabled(id, (capabilities & TaskMoveDestination::Left));
+
+ id = menu->insertItem(SmallIconSet("back"),
+ i18n("Move Left"),
+ this, TQT_SLOT(slotTaskMoveLeft()));
+ menu->setItemEnabled(id, (capabilities & TaskMoveDestination::Left));
+
+ id = menu->insertItem(SmallIconSet("forward"),
+ i18n("Move Right"),
+ this, TQT_SLOT(slotTaskMoveRight()));
+ menu->setItemEnabled(id, (capabilities & TaskMoveDestination::Right));
+
+ id = menu->insertItem(SmallIconSet("finish"),
+ i18n("Move to End"),
+ this, TQT_SLOT(slotTaskMoveEnd()));
+ menu->setItemEnabled(id, (capabilities & TaskMoveDestination::Right));
+
+ return menu;
+}
+
+void TaskContainer::slotTaskMoveBeginning()
+{
+ taskBar->taskMoveHandler(TaskMoveDestination::Beginning, taskList());
+}
+
+void TaskContainer::slotTaskMoveLeft()
+{
+ taskBar->taskMoveHandler(TaskMoveDestination::Left, taskList());
+}
+
+void TaskContainer::slotTaskMoveRight()
+{
+ taskBar->taskMoveHandler(TaskMoveDestination::Right, taskList());
+}
+
+void TaskContainer::slotTaskMoveEnd()
+{
+ taskBar->taskMoveHandler(TaskMoveDestination::End, taskList());
+}
+
void TaskContainer::mouseMoveEvent( TQMouseEvent* e )
{
kdDebug() << "regular move" << endl;
@@ -1399,11 +1451,9 @@ void TaskContainer::dragEnterEvent( TQDragEnterEvent* e )
return;
}
- if (TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange))
+ if ((e->source()->parent() == this->parent()) && TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange) && (!READ_MERGED_TASBKAR_SETTING(sortByApp)))
{
- if (!READ_MERGED_TASBKAR_SETTING(sortByApp)) {
- e->accept();
- }
+ e->accept();
}
// if a dragitem is held for over a taskbutton for two seconds,
@@ -1429,12 +1479,10 @@ void TaskContainer::dropEvent( TQDropEvent* e )
return;
}
- if (TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange))
+ if ((e->source()->parent() == this->parent()) && TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange) && (!READ_MERGED_TASBKAR_SETTING(sortByApp)))
{
- if (!READ_MERGED_TASBKAR_SETTING(sortByApp)) {
- if (taskBar->taskMoveHandler(TQWidget::mapTo(taskBar, e->pos()), TaskDrag::decode(e))) {
- e->accept();
- }
+ if (taskBar->taskMoveHandler(TaskMoveDestination::Position, TaskDrag::decode(e), TQWidget::mapTo(taskBar, e->pos()))) {
+ e->accept();
}
}
diff --git a/kicker/taskbar/taskcontainer.h b/kicker/taskbar/taskcontainer.h
index 857cd6c45..edaf337b4 100644
--- a/kicker/taskbar/taskcontainer.h
+++ b/kicker/taskbar/taskcontainer.h
@@ -127,22 +127,28 @@ protected slots:
void taskChanged(bool geometryChangeOnly);
void showMe();
+ void slotTaskMoveBeginning();
+ void slotTaskMoveLeft();
+ void slotTaskMoveRight();
+ void slotTaskMoveEnd();
+
private:
void checkAttention(const Task::Ptr changed_task = NULL);
- TQString sid;
- TQTimer animationTimer;
- TQTimer dragSwitchTimer;
- TQTimer attentionTimer;
- TQTimer m_paintEventCompressionTimer;
+ TQPopupMenu* makeTaskMoveMenu();
+ TQString sid;
+ TQTimer animationTimer;
+ TQTimer dragSwitchTimer;
+ TQTimer attentionTimer;
+ TQTimer m_paintEventCompressionTimer;
int currentFrame;
PixmapList frames;
int attentionState;
- TQRect iconRect;
- TQPixmap animBg;
+ TQRect iconRect;
+ TQPixmap animBg;
Task::List tasks;
Task::List m_filteredTasks;
Task::Ptr lastActivated;
- TQPopupMenu* m_menu;
+ TQPopupMenu* m_menu;
Startup::Ptr m_startup;
ArrowType arrowType;
TaskBar* taskBar;
diff --git a/kicker/taskmanager/taskrmbmenu.cpp b/kicker/taskmanager/taskrmbmenu.cpp
index c910c5f9d..f92719f47 100644
--- a/kicker/taskmanager/taskrmbmenu.cpp
+++ b/kicker/taskmanager/taskrmbmenu.cpp
@@ -38,10 +38,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "taskrmbmenu.h"
#include "taskrmbmenu.moc"
-TaskRMBMenu::TaskRMBMenu(const Task::List& theTasks, bool show, TQWidget *parent, const char *name)
+TaskRMBMenu::TaskRMBMenu(const Task::List& theTasks, bool show, TQPopupMenu* moveMenu, TQWidget *parent, const char *name)
: TQPopupMenu( parent, name )
, tasks( theTasks )
, showAll( show )
+ , taskMoveMenu( moveMenu )
{
assert(tasks.count() > 0);
if (tasks.count() == 1)
@@ -57,6 +58,7 @@ TaskRMBMenu::TaskRMBMenu(const Task::List& theTasks, bool show, TQWidget *parent
TaskRMBMenu::TaskRMBMenu(Task::Ptr task, bool show, TQWidget *parent, const char *name)
: TQPopupMenu( parent, name )
, showAll( show )
+ , taskMoveMenu( NULL )
{
fillMenu(task);
}
@@ -106,6 +108,13 @@ void TaskRMBMenu::fillMenu(Task::Ptr t)
insertSeparator();
+ if (taskMoveMenu) {
+ taskMoveMenu->reparent(this, taskMoveMenu->getWFlags(), taskMoveMenu->geometry().topLeft(), FALSE);
+ insertItem(i18n("Move Task Button"), taskMoveMenu);
+
+ insertSeparator();
+ }
+
id = insertItem(SmallIcon("fileclose"), i18n("&Close"), t, TQT_SLOT(close()));
setItemEnabled(id, !checkActions || t->info().actionSupported(NET::ActionClose));
}
diff --git a/kicker/taskmanager/taskrmbmenu.h b/kicker/taskmanager/taskrmbmenu.h
index d95230f9b..76b209ca7 100644
--- a/kicker/taskmanager/taskrmbmenu.h
+++ b/kicker/taskmanager/taskrmbmenu.h
@@ -32,7 +32,7 @@ class KDE_EXPORT TaskRMBMenu : public TQPopupMenu
Q_OBJECT
public:
- TaskRMBMenu(const Task::List&, bool showAll = true, TQWidget *parent = 0, const char *name = 0);
+ TaskRMBMenu(const Task::List&, bool showAll = true, TQPopupMenu* moveMenu = NULL, TQWidget *parent = 0, const char *name = 0);
TaskRMBMenu(Task::Ptr, bool showAll = true, TQWidget *parent = 0, const char *name = 0);
private:
@@ -54,6 +54,7 @@ private slots:
private:
Task::List tasks;
bool showAll;
+ TQPopupMenu* taskMoveMenu;
};
#endif