[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/multimedia/amarok/src/context
From: William Viana Soares <vianasw () gmail ! com>
Date: 2008-08-31 14:15:39
Message-ID: 1220192139.293267.29525.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 855339 by wviana:
Naive attempt to make better usage of CV space.
ToolBox menu fixing:
* alphabetical sort
* rendering issue on menu entries fixed.
* menu size adjusted to the number of applets entries to display
* other minor stuff
M +13 -4 containments/ColumnContainment.cpp
M +2 -1 widgets/ToolBoxIcon.cpp
M +54 -16 widgets/ToolBoxMenu.cpp
--- trunk/extragear/multimedia/amarok/src/context/containments/ColumnContainment.cpp \
#855338:855339 @@ -172,12 +172,10 @@
m_addAppletsMenu = new AmarokToolBoxMenu( this, false );
m_addAppletsMenu->setZValue( zValue() + 10000 ); // show over applets
- m_addAppletsMenu->setContainment( this );
m_removeAppletsMenu = new AmarokToolBoxMenu( this, true );
m_removeAppletsMenu->setZValue( zValue() + 10000 ); // show over applets
- m_removeAppletsMenu->setContainment( this );
-
+
// TODO can't add text b/c of string freeze
// add after 2.0
QAction* zoomInAction = new QAction( "Zoom In", this );
@@ -217,6 +215,15 @@
ColumnContainment::constraintsEvent( Plasma::Constraints constraints )
{
DEBUG_BLOCK
+
+ //setContainment must be done when the containment is completelly initiated
+ //otherwise the menus that receive this pointer would have problems.
+ if( constraints & Plasma::StartupCompletedConstraint )
+ {
+ m_addAppletsMenu->setContainment( this );
+ m_removeAppletsMenu->setContainment( this );
+ }
+
m_grid->setGeometry( contentsRect() );
if( m_rowHeight < m_preferredRowHeight && rect().height() / m_preferredRowHeight \
>= 4 ) @@ -609,9 +616,11 @@
consec = 0;
i++;
}
- if( consec == rowSpan )
+ //most applets should work with rowSpan of at least two rows.
+ if( consec == rowSpan || consec >= 2 )
{
positionFound = true;
+ rowSpan = consec;
row = i - rowSpan; //get the first of the consecutive rows
col = j;
}
--- trunk/extragear/multimedia/amarok/src/context/widgets/ToolBoxIcon.cpp \
#855338:855339 @@ -160,8 +160,9 @@
{
if( Plasma::Icon::drawBackground() )
{
+ QSize shapeSize( size().width() - 2, size().height() - 2 );
return Plasma::PaintUtils::roundedRectangle( QRectF( QPointF( 0.0, 0.0 ),
- QSize( 180, 24 ) \
).adjusted( -2, -2, 2,2), 10.0 ); + \
shapeSize ), 10.0 ); }
else
return Plasma::Icon::shape();
--- trunk/extragear/multimedia/amarok/src/context/widgets/ToolBoxMenu.cpp \
#855338:855339 @@ -65,16 +65,12 @@
AmarokToolBoxMenu::~AmarokToolBoxMenu()
{
- delete m_hideIcon;
- delete m_downArrow;
- delete m_upArrow;
- delete m_timer;
- delete m_scrollDelay;
}
void
AmarokToolBoxMenu::init( QMap< QString, QString > allApplets, QStringList \
appletsToShow ) {
+ DEBUG_BLOCK
setAcceptsHoverEvents( true );
m_appletsList = allApplets;
@@ -85,12 +81,11 @@
connect( m_timer, SIGNAL( timeout() ), this, SLOT( timeToHide() ) );
connect( m_scrollDelay, SIGNAL( timeout() ), this, SLOT( delayedScroll() ) );
- //insert in the stack so the first applet in alphabetical order is the first
+ //insert in the stack so the first applet in alphabetical order is the first
+ appletsToShow.sort();
for( int i = appletsToShow.size() - 1; i >= 0; i-- )
m_bottomMenu.push( appletsToShow[i] );
-
- populateMenu();
-
+
m_hideIcon = new ToolBoxIcon( this );
QAction *hideMenu = new QAction( "", this );
@@ -107,7 +102,7 @@
m_hideIcon->setMaximumSize( iconSize );
m_hideIcon->resize( m_hideIcon->size() );
- m_hideIcon->setPos( 5, boundingRect().height() - 32 * m_menuSize - 50 );
+ m_hideIcon->setPos( 5, boundingRect().height() - 32 * m_menuSize - 54 );
m_hideIcon->setZValue( zValue() + 1 );
m_hideIcon->hide();
@@ -120,8 +115,27 @@
void
AmarokToolBoxMenu::setContainment( Containment *newContainment )
{
- m_containment = newContainment;
- initRunningApplets();
+ if( m_containment != newContainment )
+ {
+ Plasma::Corona *corona = newContainment->corona();
+ if( !corona )
+ return;
+
+ //disconnect containments just in case we use setContainment somewhere else \
and we end up with + //more signals connected that we wanted
+ QList<Plasma::Containment *> containments = corona->containments();
+ foreach( Plasma::Containment *containment, containments )
+ {
+ disconnect( containment, SIGNAL( appletAdded( Plasma::Applet *, QPointF \
) ), + this, SLOT( appletAdded( Plasma::Applet *) ) );
+ disconnect( containment, SIGNAL( appletRemoved( Plasma::Applet * ) ),
+ this, SLOT( appletRemoved( Plasma::Applet * ) ) );
+ }
+
+ m_containment = newContainment;
+ initRunningApplets();
+ populateMenu();
+ }
}
Containment *
@@ -139,6 +153,9 @@
void
AmarokToolBoxMenu::populateMenu()
{
+ DEBUG_BLOCK
+
+ debug() << "menu size: " << m_menuSize;
for( int i = 0; i < m_menuSize; i++ )
{
if( m_bottomMenu.isEmpty() )
@@ -157,10 +174,10 @@
AmarokToolBoxMenu::initRunningApplets()
{
DEBUG_BLOCK
- if( !containment() )
+ if( !m_containment )
return;
- Plasma::Corona *corona = containment()->corona();
+ Plasma::Corona *corona = m_containment->corona();
if( !corona )
return;
@@ -181,6 +198,11 @@
}
m_runningApplets[containment] = appletNames;
}
+ if( m_removeApplets )
+ {
+ m_menuSize = qMin( 4, containment()->applets().size() );
+ m_hideIcon->setPos( 5, boundingRect().height() - 32 * m_menuSize - 54 );
+ }
}
void
@@ -193,6 +215,10 @@
{
m_runningApplets[containment] << applet->pluginName();
m_appletNames[applet] = applet->pluginName();
+ if( m_removeApplets )
+ {
+ m_menuSize = qMin( 4, this->containment()->applets().size() );
+ }
}
}
}
@@ -208,6 +234,10 @@
{
QString name = m_appletNames.take( applet );
m_runningApplets[containment].removeAll( name );
+ if( m_removeApplets )
+ {
+ m_menuSize = qMin( 4, this->containment()->applets().size() ); \
+ }
}
}
}
@@ -236,7 +266,10 @@
{
if( showing() )
return;
-
+
+ if( m_timer->isActive() )
+ m_timer->stop();
+
m_showing = true;
if( m_removeApplets && refreshApplets ) // we need to refresh on view to get all \
running applets @@ -258,7 +291,8 @@
boundingRect().height() - m_menuSize * height - 50 );
m_upArrow->show();
}
-
+
+ m_hideIcon->setPos( 5, boundingRect().height() - 32 * m_menuSize - 54 );
m_hideIcon->show();
for( int i = m_currentMenu.count() - 1; i >= 0; i-- )
{
@@ -277,6 +311,10 @@
{
if( !showing() )
return;
+
+ if( m_timer->isActive() )
+ m_timer->stop();
+
m_showing = false;
foreach( QGraphicsItem *c, QGraphicsItem::children() )
c->hide();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic