Commit 5d396835c187c2924946dd4a494486d7b4e1a161
- Diff rendering mode:
- inline
- side by side
src/context/ToolbarView.cpp
(9 / 0)
|   | |||
| 166 | 166 | { | |
| 167 | 167 | Context::AppletItemOverlay *moveOverlay = new Context::AppletItemOverlay( item, m_toolbar->appletLayout(), this ); | |
| 168 | 168 | connect( moveOverlay, SIGNAL( moveApplet( Plasma::Applet*, int, int ) ), m_cont, SLOT( moveApplet( Plasma::Applet*, int, int ) ) ); | |
| 169 | connect( moveOverlay, SIGNAL( moveApplet( Plasma::Applet*, int, int ) ), this, SLOT( refreshOverlays() ) ); | ||
| 169 | 170 | connect( moveOverlay, SIGNAL( deleteApplet( Plasma::Applet* ) ), this, SLOT( appletRemoved( Plasma::Applet* ) ) ); | |
| 170 | 171 | moveOverlay->setPalette( p ); | |
| 171 | 172 | moveOverlay->show(); | |
| … | … | ||
| 213 | 213 | recreateOverlays(); | |
| 214 | 214 | } | |
| 215 | 215 | ||
| 216 | |||
| 216 | 217 | void | |
| 218 | Context::ToolbarView::refreshOverlays() | ||
| 219 | { | ||
| 220 | m_toolbar->refreshAddIcons(); | ||
| 221 | } | ||
| 222 | |||
| 223 | void | ||
| 217 | 224 | Context::ToolbarView::recreateOverlays() | |
| 218 | 225 | { | |
| 219 | 226 | DEBUG_BLOCK | |
| … | … | ||
| 241 | 241 | { | |
| 242 | 242 | Context::AppletItemOverlay *moveOverlay = new Context::AppletItemOverlay( item, m_toolbar->appletLayout(), this ); | |
| 243 | 243 | connect( moveOverlay, SIGNAL( moveApplet( Plasma::Applet*, int, int ) ), m_cont, SLOT( moveApplet( Plasma::Applet*, int, int ) ) ); | |
| 244 | connect( moveOverlay, SIGNAL( moveApplet( Plasma::Applet*, int, int ) ), this, SLOT( refreshOverlays() ) ); | ||
| 244 | 245 | connect( moveOverlay, SIGNAL( deleteApplet( Plasma::Applet* ) ), this, SLOT( appletRemoved( Plasma::Applet* ) ) ); | |
| 245 | 246 | moveOverlay->setPalette( p ); | |
| 246 | 247 | moveOverlay->show(); |
src/context/ToolbarView.h
(1 / 0)
|   | |||
| 60 | 60 | void toggleConfigMode(); | |
| 61 | 61 | void appletRemoved( Plasma::Applet* ); | |
| 62 | 62 | void appletAdded( Plasma::Applet*, int); | |
| 63 | void refreshOverlays(); | ||
| 63 | 64 | void recreateOverlays(); | |
| 64 | 65 | void installApplets(); | |
| 65 | 66 | void refreshSycoca(); |
|   | |||
| 132 | 132 | // if all applets are removed, re-add the add item | |
| 133 | 133 | if( m_appletLayout->count() == 2 && m_configMode ) | |
| 134 | 134 | { | |
| 135 | toggleConfigMode(); | ||
| 135 | 136 | m_appletLayout->removeItem( m_configItem ); | |
| 136 | 137 | delete m_configItem; | |
| 137 | 138 | m_configItem = 0; | |
| … | … | ||
| 162 | 162 | DEBUG_BLOCK | |
| 163 | 163 | ||
| 164 | 164 | debug() << "inserting applet icon in position" << loc; | |
| 165 | // no config item means this is the first applet being added with no applets shown at all | ||
| 166 | 165 | if( !m_configItem ) | |
| 167 | 166 | { | |
| 168 | 167 | m_configItem = new AppletToolbarConfigItem( this ); | |
| … | … | ||
| 172 | 172 | ||
| 173 | 173 | if( m_configMode ) | |
| 174 | 174 | { | |
| 175 | // loc doesn't take into account additional + icons, also we need to add 1 more + icon | ||
| 175 | 176 | Context::AppletToolbarAppletItem* item = new Context::AppletToolbarAppletItem( this, applet ); | |
| 176 | 177 | item->setConfigEnabled( true ); | |
| 177 | 178 | connect( item, SIGNAL( appletChosen( Plasma::Applet* ) ), this, SIGNAL( showApplet( Plasma::Applet* ) ) ); | |
| 178 | |||
| 179 | |||
| 179 | 180 | // add the item | |
| 180 | 181 | m_appletLayout->insertItem( loc, item ); | |
| 181 | 182 | } | |
| … | … | ||
| 201 | 201 | DEBUG_BLOCK | |
| 202 | 202 | if( !m_configMode ) | |
| 203 | 203 | { | |
| 204 | // place add icons in all possible places that the user can add an icon | ||
| 205 | |||
| 204 | 206 | m_configMode = true; | |
| 205 | 207 | ||
| 206 | 208 | int loc = -1; // location of the configure icon | |
| … | … | ||
| 245 | 245 | emit hideAppletExplorer(); | |
| 246 | 246 | } | |
| 247 | 247 | emit configModeToggled(); | |
| 248 | } | ||
| 249 | |||
| 250 | void | ||
| 251 | Context::AppletToolbar::refreshAddIcons() // SLOT | ||
| 252 | { | ||
| 253 | foreach( AppletToolbarAddItem* item, m_configAddIcons ) | ||
| 254 | { | ||
| 255 | m_appletLayout->removeItem( item ); | ||
| 256 | item->deleteLater(); | ||
| 257 | } | ||
| 258 | m_configAddIcons.clear(); | ||
| 259 | |||
| 260 | int loc = -1; | ||
| 261 | for( int i = 0; i < m_appletLayout->count(); ++i ) | ||
| 262 | { | ||
| 263 | QGraphicsLayoutItem *item = m_appletLayout->itemAt( i ); | ||
| 264 | Context::AppletToolbarConfigItem* configItem = dynamic_cast< Context::AppletToolbarConfigItem* >( item ); | ||
| 265 | if( configItem ) | ||
| 266 | loc = i; | ||
| 267 | } | ||
| 268 | |||
| 269 | if( loc >=0 ) | ||
| 270 | newAddItem( loc ); | ||
| 248 | 271 | } | |
| 249 | 272 | ||
| 250 | 273 | void |
|   | |||
| 56 | 56 | QGraphicsLinearLayout* appletLayout(); | |
| 57 | 57 | bool configEnabled() const; | |
| 58 | 58 | ||
| 59 | void appletRemoved( Plasma::Applet* applet ); | ||
| 59 | void appletRemoved( Plasma::Applet* applet ); | ||
| 60 | |||
| 61 | void refreshAddIcons(); | ||
| 60 | 62 | signals: | |
| 61 | 63 | void showApplet( Plasma::Applet* ); | |
| 62 | 64 | void addAppletToContainment( const QString& pluginName, int loc ); |

