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
pull/2/head
Timothy Pearson 11 years ago
parent b28da13a4d
commit 18098b4c70

@ -130,6 +130,20 @@ By default this option is selected.</string>
By default, this option is selected and all windows are shown.</string>
</property>
</widget>
<widget class="TQCheckBox" row="8" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>kcfg_AllowDragAndDropReArrange</cstring>
</property>
<property name="text">
<string>&amp;Allow taskbar items to be rearranged using drag and drop</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="whatsThis" stdset="0">
<string>Turning this option on will allow tasks on the taskbar to be manually rearranged using drag and drop.</string>
</property>
</widget>
<widget class="TQCheckBox" row="7" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>kcfg_ShowWindowListBtn</cstring>
@ -144,7 +158,7 @@ By default, this option is selected and all windows are shown.</string>
<string>Selecting this option causes the taskbar to display a button that, when clicked, shows a list of all windows in a popup menu.</string>
</property>
</widget>
<widget class="TQComboBox" row="8" column="2">
<widget class="TQComboBox" row="9" column="2">
<property name="name">
<cstring>kcfg_GroupTasks</cstring>
</property>
@ -164,7 +178,7 @@ You can set the taskbar to &lt;strong&gt;Never&lt;/strong&gt; group windows, to
By default the taskbar groups windows when it is full.</string>
</property>
</widget>
<widget class="TQLabel" row="8" column="0" rowspan="1" colspan="2">
<widget class="TQLabel" row="9" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>groupTasksLabel</cstring>
</property>
@ -175,7 +189,7 @@ By default the taskbar groups windows when it is full.</string>
<cstring>kcfg_ShowTaskStates</cstring>
</property>
</widget>
<widget class="TQComboBox" row="9" column="2">
<widget class="TQComboBox" row="10" column="2">
<property name="name">
<cstring>kcfg_ShowTaskStates</cstring>
</property>
@ -191,7 +205,7 @@ By default the taskbar groups windows when it is full.</string>
<string>The taskbar can show and/or hide tasks based on their current process state. Select &lt;em&gt;Any&lt;/em&gt; to show all tasks regardless of current state.</string>
</property>
</widget>
<widget class="TQLabel" row="9" column="0" rowspan="1" colspan="2">
<widget class="TQLabel" row="10" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>showTaskStatesLabel</cstring>
</property>
@ -247,12 +261,12 @@ By default this option is selected.</string>
By default, this option is selected and all windows are shown.</string>
</property>
</widget>
<widget class="TQComboBox" row="10" column="2">
<widget class="TQComboBox" row="11" column="2">
<property name="name">
<cstring>appearance</cstring>
</property>
</widget>
<widget class="TQLabel" row="10" column="0" rowspan="1" colspan="2">
<widget class="TQLabel" row="11" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>textLabel1</cstring>
</property>
@ -263,7 +277,7 @@ By default, this option is selected and all windows are shown.</string>
<cstring>appearance</cstring>
</property>
</widget>
<widget class="TQCheckBox" row="11" column="0" rowspan="1" colspan="2">
<widget class="TQCheckBox" row="12" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>kcfg_UseCustomColors</cstring>
</property>
@ -277,7 +291,7 @@ By default, this option is selected and all windows are shown.</string>
<bool>true</bool>
</property>
</widget>
<widget class="TQLayoutWidget" row="12" column="0" rowspan="1" colspan="3">
<widget class="TQLayoutWidget" row="13" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>layout9</cstring>
</property>

@ -56,6 +56,9 @@ KButton::KButton( TQWidget* parent )
setButtonText(KickerSettings::kMenuText());
setFont(KickerSettings::buttonFont());
setTextColor(KickerSettings::buttonTextColor());
setMaximumHeight(30);
setMaximumWidth(widthForHeight(30));
setCenterButtonInContainer(false);
}
}
@ -64,6 +67,26 @@ KButton::~KButton()
MenuManager::the()->unregisterKButton(this);
}
int KButton::widthForHeight(int height) const
{
if (KickerSettings::showKMenuText()) {
return PanelPopupButton::widthForHeight(30);
}
else {
return PanelPopupButton::widthForHeight(height);
}
}
int KButton::heightForWidth(int width) const
{
if (KickerSettings::showKMenuText()) {
return 30;
}
else {
return PanelPopupButton::heightForWidth(width);
}
}
void KButton::properties()
{
TDEApplication::startServiceByDesktopName("kmenuedit", TQStringList(),

@ -41,6 +41,18 @@ public:
virtual void properties();
/**
* Reimplement this to give Kicker a hint for the width of the button
* given a certain height.
*/
virtual int widthForHeight(int height) const;
/**
* Reimplement this to give Kicker a hint for the height of the button
* given a certain width.
*/
virtual int heightForWidth(int width) const;
protected:
virtual TQString tileName() { return "KMenu"; }
virtual void initPopup();

@ -145,12 +145,17 @@ void ButtonContainer::embedButton(PanelButton* b)
{
if (!b) return;
delete _layout;
_layout = new TQVBoxLayout(this);
_button = b;
if (_layout) delete _layout;
_button = b;
_button->installEventFilter(this);
_layout->add(_button);
if (b->centerButtonInContainer()) {
TQVBoxLayout* vbox = new TQVBoxLayout(this);
vbox->addWidget(_button);
_layout = vbox;
}
connect(_button, TQT_SIGNAL(requestSave()), TQT_SIGNAL(requestSave()));
connect(_button, TQT_SIGNAL(hideme(bool)), TQT_SLOT(hideRequested(bool)));
connect(_button, TQT_SIGNAL(removeme()), TQT_SLOT(removeRequested()));

@ -70,6 +70,7 @@ PanelButton::PanelButton( TQWidget* parent, const char* name, bool forceStandard
m_highlight(false),
m_changeCursorOverItem(forceStandardCursor?false:true),
m_hasAcceptedDrag(false),
m_centerInContainer(true),
m_arrowDirection(KPanelExtension::Bottom),
m_popupDirection(KPanelApplet::Up),
m_iconAlignment(AlignCenter),
@ -938,6 +939,10 @@ bool PanelButton::calculateIconSize()
return false;
}
void PanelButton::setCenterButtonInContainer(bool center) {
m_centerInContainer = center;
}
void PanelButton::updateKickerTip(KickerTip::Data& data)
{
data.message = TQStyleSheet::escape(title());
@ -946,6 +951,11 @@ void PanelButton::updateKickerTip(KickerTip::Data& data)
data.direction = popupDirection();
}
bool PanelButton::centerButtonInContainer()
{
return m_centerInContainer;
}
//
// PanelPopupButton class
//

@ -205,6 +205,11 @@ public:
*/
void updateKickerTip(KickerTip::Data& data);
/**
* @return true if the button should be centered in its parent container, false if not
*/
bool centerButtonInContainer();
signals:
/**
* Emitted when the button's icon is changed.
@ -347,6 +352,11 @@ protected:
*/
bool calculateIconSize();
/**
* @param center true if the button should be centered in its parent container, false if not
*/
void setCenterButtonInContainer(bool center);
bool m_valid;
TQPixmap m_icon;
@ -382,6 +392,7 @@ private:
bool m_highlight;
bool m_changeCursorOverItem;
bool m_hasAcceptedDrag;
bool m_centerInContainer;
TQColor m_textColor;
TQColor m_tileColor;
TQString m_buttonText;

@ -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;
}

@ -65,6 +65,8 @@ public:
KTextShadowEngine *textShadowEngine();
int taskMoveHandler(const TQPoint &pos, Task::List taskList);
public slots:
void configure();
void setBackground();

@ -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>

@ -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();
}
}
}
}

@ -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();

@ -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();

@ -90,6 +90,8 @@ public:
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);

Loading…
Cancel
Save