Skip to content

Commit

Permalink
Add maximum size of task so tasks never be wider than widget
Browse files Browse the repository at this point in the history
Add tooltip
  • Loading branch information
grulja committed Mar 12, 2012
1 parent 8d36f91 commit d5eec3c
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 44 deletions.
109 changes: 66 additions & 43 deletions tasks/config.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>313</width>
<width>314</width>
<height>230</height>
</rect>
</property>
Expand All @@ -19,41 +19,30 @@
<property name="windowTitle">
<string>Configuration</string>
</property>
<widget class="QWidget" name="layoutWidget">
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>0</x>
<y>99</y>
<width>301</width>
<height>41</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>311</width>
<height>158</height>
<height>111</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="verticalSpacing">
<number>5</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Automatically delete
completed tasks</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="autoHide">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Collections&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
Expand All @@ -63,8 +52,14 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item>
<widget class="QListWidget" name="collectionsList">
<property name="maximumSize">
<size>
<width>180</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
Expand All @@ -85,12 +80,12 @@
</property>
</widget>
</item>
<item row="0" column="2" alignment="Qt::AlignTop">
<item alignment="Qt::AlignTop">
<widget class="QPushButton" name="loadCollections">
<property name="maximumSize">
<size>
<width>25</width>
<height>25</height>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
Expand All @@ -101,8 +96,33 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="autoDel">
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>0</x>
<y>130</y>
<width>311</width>
<height>41</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Hide completed tasks</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="autoHide">
<property name="enabled">
<bool>true</bool>
</property>
Expand All @@ -111,17 +131,20 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Hide completed
tasks</string>
<string>Automatically delete completed tasks</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="autoDel">
<property name="enabled">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>false</bool>
<property name="text">
<string/>
</property>
</widget>
</item>
Expand Down
11 changes: 10 additions & 1 deletion tasks/plasmatasks.cpp
Expand Up @@ -51,7 +51,7 @@ QGraphicsWidget * PlasmaTasks::graphicsWidget()
m_widget = new QGraphicsWidget(this);

m_widget->setMinimumSize(300, 500);

m_tasksList = new TaskWidget(m_widget);

m_scroll = new Plasma::ScrollWidget(m_widget);
Expand All @@ -77,11 +77,20 @@ QGraphicsWidget * PlasmaTasks::graphicsWidget()

configChanged();

connect(m_widget,SIGNAL(geometryChanged()),SLOT(updateTaskListWidth()));
}

return m_widget;
}

void PlasmaTasks::updateTaskListWidth()
{

m_tasksList->updateTasksWidth((int)geometry().width());

}


void PlasmaTasks::configChanged()
{

Expand Down
2 changes: 2 additions & 0 deletions tasks/plasmatasks.h
Expand Up @@ -59,6 +59,8 @@ class PlasmaTasks : public Plasma::PopupApplet {

private slots:

void updateTaskListWidth();

void configAccepted();

void createTask();
Expand Down
17 changes: 17 additions & 0 deletions tasks/taskwidget.cpp
Expand Up @@ -30,6 +30,7 @@ TaskWidget::TaskWidget(QGraphicsWidget * parent)
m_todayColor("#e64600"),
m_weekColor("#e6f000"),
m_otherColor(""),
m_taskWidth(300),
m_autoHide(false),
m_autoDel(false),
m_order(DNC)
Expand Down Expand Up @@ -106,6 +107,22 @@ void TaskWidget::setCollections(QList<Akonadi::Entity::Id> ids)

}

void TaskWidget::updateTasksWidth(int width)
{

m_taskWidth = width;

TaskWidgetItem * item;

for (int i = 0; i < m_layout->count(); i++) {

item = static_cast<TaskWidgetItem*>(m_layout->itemAt(i));

item->setMaxWidth(width);
}

}

void TaskWidget::fetchCollections()
{

Expand Down
10 changes: 10 additions & 0 deletions tasks/taskwidget.h
Expand Up @@ -76,6 +76,10 @@ class TaskWidget : public QGraphicsWidget {
return m_autoDel;
}

int taskWidth() {
return m_taskWidth;
}

void setExpiredColor(QString color);
void setTodayColor(QString color);
void setWeekColor(QString color);
Expand All @@ -87,6 +91,10 @@ class TaskWidget : public QGraphicsWidget {

void setCollections(QList<Akonadi::Collection::Id> ids);

public slots:

void updateTasksWidth(int width);

private slots:

void fetchCollectionsFinished(KJob * job);
Expand Down Expand Up @@ -114,6 +122,8 @@ class TaskWidget : public QGraphicsWidget {
QString m_weekColor;
QString m_otherColor;

int m_taskWidth;

bool m_autoHide;
bool m_autoDel;

Expand Down
28 changes: 28 additions & 0 deletions tasks/taskwidgetitem.cpp
Expand Up @@ -103,19 +103,39 @@ void TaskWidgetItem::setItemInfo()

}

Plasma::ToolTipContent content(m_todo->summary(), m_todo->description());

if (m_todo->isCompleted()) {

content.setImage(KIcon("dialog-ok"));

} else {

content.setImage(KIcon("edit-delete"));

}

Plasma::ToolTipManager::self()->setContent(m_name, content);

connect(m_name, SIGNAL(clicked()), SLOT(editTask()));

if (m_date) {

Plasma::ToolTipManager::self()->setContent(m_date, content);

connect(m_date, SIGNAL(clicked()), SLOT(editTask()));

}

setMaxWidth(((TaskWidget*)parentWidget())->taskWidth());

}

void TaskWidgetItem::TaskWidgetItem::editTask()
{

qDebug() << (int)parentWidget()->geometry().width();

m_editor = new TaskEditor();

m_editor->setAllDay(m_todo->allDay());
Expand Down Expand Up @@ -244,6 +264,14 @@ void TaskWidgetItem::setUnrelated()
m_indent = 0;
}

void TaskWidgetItem::setMaxWidth(int width)
{

m_name->setMaximumWidth(width-(m_indent*25)-5-70);

}


void TaskWidgetItem::updateTask(const Akonadi::Item & item)
{

Expand Down
2 changes: 2 additions & 0 deletions tasks/taskwidgetitem.h
Expand Up @@ -73,6 +73,8 @@ class TaskWidgetItem : public Plasma::Frame {
return m_item;
}

void setMaxWidth(int width);

public slots:

void setCompleted(bool completed);
Expand Down

0 comments on commit d5eec3c

Please sign in to comment.