00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "katemdi.h"
00024
00025 #include <kdebug.h>
00026 #include <kglobalsettings.h>
00027 #include <kapplication.h>
00028 #include <klocale.h>
00029 #include <kconfig.h>
00030 #include <kiconloader.h>
00031 #include <kpopupmenu.h>
00032
00033
00034 namespace KateMDI {
00035
00036
00037
00038 Splitter::Splitter(Orientation o, QWidget* parent, const char* name)
00039 : QSplitter(o, parent, name)
00040 {
00041 }
00042
00043 Splitter::~Splitter()
00044 {
00045 }
00046
00047 bool Splitter::isLastChild(QWidget* w) const
00048 {
00049 return ( idAfter( w ) == 0 );
00050 }
00051
00052 int Splitter::idAfter ( QWidget * w ) const
00053 {
00054 return QSplitter::idAfter (w);
00055 }
00056
00057
00058
00059
00060
00061
00062 ToggleToolViewAction::ToggleToolViewAction ( const QString& text, const KShortcut& cut, ToolView *tv,
00063 QObject* parent, const char* name )
00064 : KToggleAction(text,cut,parent,name)
00065 , m_tv(tv)
00066 {
00067 connect(this,SIGNAL(toggled(bool)),this,SLOT(slotToggled(bool)));
00068 connect(m_tv,SIGNAL(visibleChanged(bool)),this,SLOT(visibleChanged(bool)));
00069
00070 setChecked(m_tv->visible());
00071 }
00072
00073 ToggleToolViewAction::~ToggleToolViewAction()
00074 {
00075 unplugAll();
00076 }
00077
00078 void ToggleToolViewAction::visibleChanged(bool)
00079 {
00080 if (isChecked() != m_tv->visible())
00081 setChecked (m_tv->visible());
00082 }
00083
00084 void ToggleToolViewAction::slotToggled(bool t)
00085 {
00086 if (t)
00087 {
00088 m_tv->mainWindow()->showToolView (m_tv);
00089 m_tv->setFocus ();
00090 }
00091 else
00092 {
00093 m_tv->mainWindow()->hideToolView (m_tv);
00094 m_tv->mainWindow()->centralWidget()->setFocus ();
00095 }
00096 }
00097
00098
00099
00100
00101
00102
00103 GUIClient::GUIClient ( MainWindow *mw )
00104 : QObject ( mw )
00105 , KXMLGUIClient ( mw )
00106 , m_mw (mw)
00107 {
00108 connect( m_mw->guiFactory(), SIGNAL( clientAdded( KXMLGUIClient * ) ),
00109 this, SLOT( clientAdded( KXMLGUIClient * ) ) );
00110
00111 if (actionCollection()->kaccel()==0)
00112 actionCollection()->setWidget(m_mw);
00113
00114
00115
00116 actionCollection()->readShortcutSettings( "Shortcuts", kapp->config() );
00117 }
00118
00119 GUIClient::~GUIClient()
00120 {
00121 }
00122
00123 void GUIClient::registerToolView (ToolView *tv)
00124 {
00125 QString aname = QString("kate_mdi_toolview_") + tv->id;
00126
00127
00128 KShortcut sc;
00129 KConfig *cfg = kapp->config();
00130 QString _grp = cfg->group();
00131 cfg->setGroup("Shortcuts");
00132 sc = KShortcut( cfg->readEntry( aname, "" ) );
00133 cfg->setGroup( _grp );
00134 }
00135
00136 void GUIClient::clientAdded( KXMLGUIClient *client )
00137 {
00138 if ( client == this )
00139 updateActions();
00140 }
00141
00142 void GUIClient::updateActions()
00143 {
00144 if ( !factory() )
00145 return;
00146 }
00147
00148
00149
00150
00151
00152
00153 ToolView::ToolView (MainWindow *mainwin, Sidebar *sidebar, QWidget *parent)
00154 : QVBox (parent)
00155 , m_mainWin (mainwin)
00156 , m_sidebar (sidebar)
00157 , m_visible (false)
00158 , persistent (false)
00159 {
00160 }
00161
00162 ToolView::~ToolView ()
00163 {
00164 m_mainWin->toolViewDeleted (this);
00165 }
00166
00167 void ToolView::setVisible (bool vis)
00168 {
00169 if (m_visible == vis)
00170 return;
00171
00172 m_visible = vis;
00173 emit visibleChanged (m_visible);
00174 }
00175
00176 bool ToolView::visible () const
00177 {
00178 return m_visible;
00179 }
00180
00181 void ToolView::childEvent ( QChildEvent *ev )
00182 {
00183
00184 if (ev->inserted() && ev->child() && ev->child()->qt_cast("QWidget"))
00185 setFocusProxy ((QWidget *)(ev->child()->qt_cast("QWidget")));
00186
00187 QVBox::childEvent (ev);
00188 }
00189
00190
00191
00192
00193
00194
00195 Sidebar::Sidebar (KMultiTabBar::KMultiTabBarPosition pos, MainWindow *mainwin, QWidget *parent)
00196 : KMultiTabBar ((pos == KMultiTabBar::Top || pos == KMultiTabBar::Bottom) ? KMultiTabBar::Horizontal : KMultiTabBar::Vertical, parent)
00197 , m_mainWin (mainwin)
00198 , m_splitter (0)
00199 , m_ownSplit (0)
00200 , m_lastSize (0)
00201 {
00202 setSidebarPosition( pos );
00203 hide ();
00204 }
00205
00206 Sidebar::~Sidebar ()
00207 {
00208 }
00209
00210 void Sidebar::setSidebarPosition( KMultiTabBarPosition pos )
00211 {
00212 m_pos = pos;
00213 setPosition(pos);
00214 }
00215
00216 void Sidebar::setSidebarStyle( KMultiTabBarStyle style )
00217 {
00218 m_sidebarTabStyle = style;
00219 setStyle(style);
00220 }
00221
00222 void Sidebar::setSplitter (Splitter *sp)
00223 {
00224 m_splitter = sp;
00225 m_ownSplit = new Splitter ((sidebarPosition() == KMultiTabBar::Top || sidebarPosition() == KMultiTabBar::Bottom) ? Qt::Horizontal : Qt::Vertical, m_splitter);
00226 m_ownSplit->setOpaqueResize( KGlobalSettings::opaqueResize() );
00227 m_ownSplit->setChildrenCollapsible( false );
00228 m_splitter->setResizeMode( m_ownSplit, QSplitter::KeepSize );
00229 m_ownSplit->hide ();
00230 }
00231
00232 ToolView *Sidebar::addWidget (const QPixmap &icon, const QString &text, ToolView *widget)
00233 {
00234 static int id = 0;
00235
00236 if (widget)
00237 {
00238 if (widget->sidebar() == this)
00239 return widget;
00240
00241 widget->sidebar()->removeWidget (widget);
00242 }
00243
00244 int newId = ++id;
00245
00246 appendTab (icon, newId, text);
00247
00248 if (!widget)
00249 {
00250 widget = new ToolView (m_mainWin, this, m_ownSplit);
00251 widget->hide ();
00252 widget->icon = icon;
00253 widget->text = text;
00254 }
00255 else
00256 {
00257 widget->hide ();
00258 widget->reparent (m_ownSplit, 0, QPoint());
00259 widget->m_sidebar = this;
00260 }
00261
00262
00263 widget->persistent = false;
00264
00265 m_idToWidget.insert (newId, widget);
00266 m_widgetToId.insert (widget, newId);
00267 m_toolviews.push_back (widget);
00268
00269 show ();
00270
00271 connect(tab(newId),SIGNAL(clicked(int)),this,SLOT(tabClicked(int)));
00272 tab(newId)->installEventFilter(this);
00273
00274 return widget;
00275 }
00276
00277 bool Sidebar::removeWidget (ToolView *widget)
00278 {
00279 if (!m_widgetToId.contains(widget))
00280 return false;
00281
00282 removeTab(m_widgetToId[widget]);
00283
00284 m_idToWidget.remove (m_widgetToId[widget]);
00285 m_widgetToId.remove (widget);
00286 m_toolviews.remove (widget);
00287
00288 bool anyVis = false;
00289 QIntDictIterator<ToolView> it( m_idToWidget );
00290 for ( ; it.current(); ++it )
00291 {
00292 if (!anyVis)
00293 anyVis = it.current()->isVisible();
00294 }
00295
00296 if (m_idToWidget.isEmpty())
00297 {
00298 m_ownSplit->hide ();
00299 hide ();
00300 }
00301 else if (!anyVis)
00302 m_ownSplit->hide ();
00303
00304 return true;
00305 }
00306
00307 bool Sidebar::showWidget (ToolView *widget)
00308 {
00309 if (!m_widgetToId.contains(widget))
00310 return false;
00311
00312
00313 QIntDictIterator<ToolView> it( m_idToWidget );
00314 for ( ; it.current(); ++it )
00315 if ((it.current() != widget) && !it.current()->persistent)
00316 {
00317 it.current()->hide();
00318 setTab (it.currentKey(), false);
00319 it.current()->setVisible(false);
00320 }
00321
00322 setTab (m_widgetToId[widget], true);
00323
00324 m_ownSplit->show ();
00325 widget->show ();
00326
00327 widget->setVisible (true);
00328
00329 return true;
00330 }
00331
00332 bool Sidebar::hideWidget (ToolView *widget)
00333 {
00334 if (!m_widgetToId.contains(widget))
00335 return false;
00336
00337 bool anyVis = false;
00338
00339 updateLastSize ();
00340
00341 for ( QIntDictIterator<ToolView> it( m_idToWidget ); it.current(); ++it )
00342 {
00343 if (it.current() == widget)
00344 {
00345 it.current()->hide();
00346 continue;
00347 }
00348
00349 if (!anyVis)
00350 anyVis = it.current()->isVisible();
00351 }
00352
00353
00354 setTab (m_widgetToId[widget], false);
00355
00356 if (!anyVis)
00357 m_ownSplit->hide ();
00358
00359 widget->setVisible (false);
00360
00361 return true;
00362 }
00363
00364 void Sidebar::tabClicked(int i)
00365 {
00366 ToolView *w = m_idToWidget[i];
00367
00368 if (!w)
00369 return;
00370
00371 if (isTabRaised(i))
00372 {
00373 showWidget (w);
00374 w->setFocus ();
00375 }
00376 else
00377 {
00378 hideWidget (w);
00379 m_mainWin->centralWidget()->setFocus ();
00380 }
00381 }
00382
00383 bool Sidebar::eventFilter(QObject *obj, QEvent *ev)
00384 {
00385 if (ev->type()==QEvent::ContextMenu)
00386 {
00387 QContextMenuEvent *e = (QContextMenuEvent *) ev;
00388 KMultiTabBarTab *bt = dynamic_cast<KMultiTabBarTab*>(obj);
00389 if (bt)
00390 {
00391 kdDebug()<<"Request for popup"<<endl;
00392
00393 m_popupButton = bt->id();
00394
00395 ToolView *w = m_idToWidget[m_popupButton];
00396
00397 if (w)
00398 {
00399 KPopupMenu *p = new KPopupMenu (this);
00400
00401 p->insertTitle(SmallIcon("view_remove"), i18n("Behavior"), 50);
00402
00403 p->insertItem(w->persistent ? SmallIconSet("window_nofullscreen") : SmallIconSet("window_fullscreen"), w->persistent ? i18n("Make Non-Persistent") : i18n("Make Persistent"), 10);
00404
00405 p->insertTitle(SmallIcon("move"), i18n("Move To"), 51);
00406
00407 if (sidebarPosition() != 0)
00408 p->insertItem(SmallIconSet("back"), i18n("Left Sidebar"),0);
00409
00410 if (sidebarPosition() != 1)
00411 p->insertItem(SmallIconSet("forward"), i18n("Right Sidebar"),1);
00412
00413 if (sidebarPosition() != 2)
00414 p->insertItem(SmallIconSet("up"), i18n("Top Sidebar"),2);
00415
00416 if (sidebarPosition() != 3)
00417 p->insertItem(SmallIconSet("down"), i18n("Bottom Sidebar"),3);
00418
00419 connect(p, SIGNAL(activated(int)),
00420 this, SLOT(buttonPopupActivate(int)));
00421
00422 p->exec(e->globalPos());
00423 delete p;
00424
00425 return true;
00426 }
00427 }
00428 }
00429
00430 return false;
00431 }
00432
00433 void Sidebar::buttonPopupActivate (int id)
00434 {
00435 ToolView *w = m_idToWidget[m_popupButton];
00436
00437 if (!w)
00438 return;
00439
00440
00441 if (id < 4)
00442 {
00443
00444 m_mainWin->moveToolView (w, (KMultiTabBar::KMultiTabBarPosition) id);
00445 m_mainWin->showToolView (w);
00446 }
00447
00448
00449 if (id == 10)
00450 w->persistent = !w->persistent;
00451 }
00452
00453 void Sidebar::updateLastSize ()
00454 {
00455 QValueList<int> s = m_splitter->sizes ();
00456
00457 int i = 0;
00458 if ((sidebarPosition() == KMultiTabBar::Right || sidebarPosition() == KMultiTabBar::Bottom))
00459 i = 2;
00460
00461
00462 if (s[i] > 2)
00463 m_lastSize = s[i];
00464 }
00465
00466 class TmpToolViewSorter
00467 {
00468 public:
00469 ToolView *tv;
00470 unsigned int pos;
00471 };
00472
00473 void Sidebar::restoreSession (KConfig *config)
00474 {
00475
00476 unsigned int firstWrong = 0;
00477 for ( ; firstWrong < m_toolviews.size(); ++firstWrong )
00478 {
00479 ToolView *tv = m_toolviews[firstWrong];
00480
00481 unsigned int pos = config->readUnsignedNumEntry (QString ("Kate-MDI-ToolView-%1-Sidebar-Position").arg(tv->id), firstWrong);
00482
00483 if (pos != firstWrong)
00484 break;
00485 }
00486
00487
00488 if (firstWrong < m_toolviews.size())
00489 {
00490
00491 QValueList<TmpToolViewSorter> toSort;
00492 for (unsigned int i=firstWrong; i < m_toolviews.size(); ++i)
00493 {
00494 TmpToolViewSorter s;
00495 s.tv = m_toolviews[i];
00496 s.pos = config->readUnsignedNumEntry (QString ("Kate-MDI-ToolView-%1-Sidebar-Position").arg(m_toolviews[i]->id), i);
00497 toSort.push_back (s);
00498 }
00499
00500
00501 for (unsigned int m=0; m < toSort.size(); ++m)
00502 for (unsigned int n=m+1; n < toSort.size(); ++n)
00503 if (toSort[n].pos < toSort[m].pos)
00504 {
00505 TmpToolViewSorter tmp = toSort[n];
00506 toSort[n] = toSort[m];
00507 toSort[m] = tmp;
00508 }
00509
00510
00511
00512 for (int i=m_toolviews.size()-1; i >= (int)firstWrong; --i)
00513 {
00514 removeTab (m_widgetToId[m_toolviews[i]]);
00515 }
00516
00517
00518 for (unsigned int i=0; i < toSort.size(); ++i)
00519 {
00520 ToolView *tv = toSort[i].tv;
00521
00522 m_toolviews[firstWrong+i] = tv;
00523
00524
00525 int newId = m_widgetToId[tv];
00526 appendTab (tv->icon, newId, tv->text);
00527 connect(tab(newId),SIGNAL(clicked(int)),this,SLOT(tabClicked(int)));
00528 tab(newId)->installEventFilter(this);
00529
00530
00531 m_ownSplit->moveToLast (tv);
00532 }
00533 }
00534
00535
00536 updateLastSize ();
00537
00538
00539 QValueList<int> s = config->readIntListEntry (QString ("Kate-MDI-Sidebar-%1-Splitter").arg(sidebarPosition()));
00540 m_ownSplit->setSizes (s);
00541
00542
00543 bool anyVis = false;
00544 for ( unsigned int i=0; i < m_toolviews.size(); ++i )
00545 {
00546 ToolView *tv = m_toolviews[i];
00547
00548 tv->persistent = config->readBoolEntry (QString ("Kate-MDI-ToolView-%1-Persistent").arg(tv->id), false);
00549 tv->setVisible (config->readBoolEntry (QString ("Kate-MDI-ToolView-%1-Visible").arg(tv->id), false));
00550
00551 if (!anyVis)
00552 anyVis = tv->visible();
00553
00554 setTab (m_widgetToId[tv],tv->visible());
00555
00556 if (tv->visible())
00557 tv->show();
00558 else
00559 tv->hide ();
00560 }
00561
00562 if (anyVis)
00563 m_ownSplit->show();
00564 else
00565 m_ownSplit->hide();
00566 }
00567
00568 void Sidebar::saveSession (KConfig *config)
00569 {
00570
00571 QValueList<int> s = m_ownSplit->sizes();
00572 config->writeEntry (QString ("Kate-MDI-Sidebar-%1-Splitter").arg(sidebarPosition()), s);
00573
00574
00575 for ( unsigned int i=0; i < m_toolviews.size(); ++i )
00576 {
00577 ToolView *tv = m_toolviews[i];
00578
00579 config->writeEntry (QString ("Kate-MDI-ToolView-%1-Position").arg(tv->id), tv->sidebar()->sidebarPosition());
00580 config->writeEntry (QString ("Kate-MDI-ToolView-%1-Sidebar-Position").arg(tv->id), i);
00581 config->writeEntry (QString ("Kate-MDI-ToolView-%1-Visible").arg(tv->id), tv->visible());
00582 config->writeEntry (QString ("Kate-MDI-ToolView-%1-Persistent").arg(tv->id), tv->persistent);
00583 }
00584 }
00585
00586
00587
00588
00589
00590
00591 MainWindow::MainWindow (QWidget* parentWidget, const char* name)
00592 : KParts::MainWindow( parentWidget, name)
00593 , m_restoreConfig (0)
00594 , m_guiClient (new GUIClient (this))
00595 {
00596
00597 QHBox *hb = new QHBox (this);
00598 setCentralWidget(hb);
00599
00600 m_sidebars[KMultiTabBar::Left] = new Sidebar (KMultiTabBar::Left, this, hb);
00601
00602 m_hSplitter = new Splitter (Qt::Horizontal, hb);
00603 m_hSplitter->setOpaqueResize( KGlobalSettings::opaqueResize() );
00604
00605 m_sidebars[KMultiTabBar::Left]->setSplitter (m_hSplitter);
00606
00607 QVBox *vb = new QVBox (m_hSplitter);
00608 m_hSplitter->setCollapsible(vb, false);
00609
00610 m_sidebars[KMultiTabBar::Top] = new Sidebar (KMultiTabBar::Top, this, vb);
00611
00612 m_vSplitter = new Splitter (Qt::Vertical, vb);
00613 m_vSplitter->setOpaqueResize( KGlobalSettings::opaqueResize() );
00614
00615 m_sidebars[KMultiTabBar::Top]->setSplitter (m_vSplitter);
00616
00617 m_centralWidget = new QVBox (m_vSplitter);
00618 m_vSplitter->setCollapsible(m_centralWidget, false);
00619
00620 m_sidebars[KMultiTabBar::Bottom] = new Sidebar (KMultiTabBar::Bottom, this, vb);
00621 m_sidebars[KMultiTabBar::Bottom]->setSplitter (m_vSplitter);
00622
00623 m_sidebars[KMultiTabBar::Right] = new Sidebar (KMultiTabBar::Right, this, hb);
00624 m_sidebars[KMultiTabBar::Right]->setSplitter (m_hSplitter);
00625 }
00626
00627 MainWindow::~MainWindow ()
00628 {
00629
00630 while(!m_toolviews.isEmpty()) delete m_toolviews[0];
00631
00632
00633 delete m_centralWidget;
00634
00635 for (unsigned int i=0; i < 4; ++i) delete m_sidebars[i];
00636 }
00637
00638 QWidget *MainWindow::centralWidget () const
00639 {
00640 return m_centralWidget;
00641 }
00642
00643 ToolView *MainWindow::createToolView (const QString &identifier, KMultiTabBar::KMultiTabBarPosition pos, const QPixmap &icon, const QString &text)
00644 {
00645 if (m_idToWidget[identifier])
00646 return 0;
00647
00648
00649 if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
00650 {
00651 m_restoreConfig->setGroup (m_restoreGroup);
00652 pos = (KMultiTabBar::KMultiTabBarPosition) m_restoreConfig->readNumEntry (QString ("Kate-MDI-ToolView-%1-Position").arg(identifier), pos);
00653 }
00654
00655 ToolView *v = m_sidebars[pos]->addWidget (icon, text, 0);
00656 v->id = identifier;
00657
00658 m_idToWidget.insert (identifier, v);
00659 m_toolviews.push_back (v);
00660
00661
00662 m_guiClient->registerToolView (v);
00663
00664 return v;
00665 }
00666
00667 ToolView *MainWindow::toolView (const QString &identifier) const
00668 {
00669 return m_idToWidget[identifier];
00670 }
00671
00672 void MainWindow::toolViewDeleted (ToolView *widget)
00673 {
00674 if (!widget)
00675 return;
00676
00677 if (widget->mainWindow() != this)
00678 return;
00679
00680
00681
00682 widget->sidebar()->removeWidget (widget);
00683
00684 m_idToWidget.remove (widget->id);
00685 m_toolviews.remove (widget);
00686 }
00687
00688 void MainWindow::setToolViewStyle (KMultiTabBar::KMultiTabBarStyle style)
00689 {
00690 m_sidebars[0]->setSidebarStyle(style);
00691 m_sidebars[1]->setSidebarStyle(style);
00692 m_sidebars[2]->setSidebarStyle(style);
00693 m_sidebars[3]->setSidebarStyle(style);
00694 }
00695
00696 KMultiTabBar::KMultiTabBarStyle MainWindow::toolViewStyle () const
00697 {
00698
00699 return m_sidebars[KMultiTabBar::Top]->sidebarTabStyle();
00700 }
00701
00702 bool MainWindow::moveToolView (ToolView *widget, KMultiTabBar::KMultiTabBarPosition pos)
00703 {
00704 if (!widget || widget->mainWindow() != this)
00705 return false;
00706
00707
00708 if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
00709 {
00710 m_restoreConfig->setGroup (m_restoreGroup);
00711 pos = (KMultiTabBar::KMultiTabBarPosition) m_restoreConfig->readNumEntry (QString ("Kate-MDI-ToolView-%1-Position").arg(widget->id), pos);
00712 }
00713
00714 m_sidebars[pos]->addWidget (widget->icon, widget->text, widget);
00715
00716 return true;
00717 }
00718
00719 bool MainWindow::showToolView (ToolView *widget)
00720 {
00721 if (!widget || widget->mainWindow() != this)
00722 return false;
00723
00724
00725 if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
00726 return true;
00727
00728 return widget->sidebar()->showWidget (widget);
00729 }
00730
00731 bool MainWindow::hideToolView (ToolView *widget)
00732 {
00733 if (!widget || widget->mainWindow() != this)
00734 return false;
00735
00736
00737 if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
00738 return true;
00739
00740 return widget->sidebar()->hideWidget (widget);
00741 }
00742
00743 void MainWindow::startRestore (KConfig *config, const QString &group)
00744 {
00745
00746 m_restoreConfig = config;
00747 m_restoreGroup = group;
00748
00749 if (!m_restoreConfig || !m_restoreConfig->hasGroup (m_restoreGroup))
00750 {
00751
00752 QValueList<int> hs;
00753 hs << 220 << 100 << 230;
00754 QValueList<int> vs;
00755 vs << 0 << 100 << 150;
00756
00757 m_sidebars[0]->setLastSize (hs[0]);
00758 m_sidebars[1]->setLastSize (hs[2]);
00759 m_sidebars[2]->setLastSize (vs[0]);
00760 m_sidebars[3]->setLastSize (vs[2]);
00761
00762 m_hSplitter->setSizes(hs);
00763 m_vSplitter->setSizes(vs);
00764
00765
00766 return;
00767 }
00768
00769
00770 m_restoreConfig->setGroup (m_restoreGroup);
00771 restoreWindowSize (m_restoreConfig);
00772
00773 m_restoreConfig->setGroup (m_restoreGroup);
00774
00775
00776 QValueList<int> hs = m_restoreConfig->readIntListEntry ("Kate-MDI-H-Splitter");
00777 QValueList<int> vs = m_restoreConfig->readIntListEntry ("Kate-MDI-V-Splitter");
00778
00779 m_sidebars[0]->setLastSize (hs[0]);
00780 m_sidebars[1]->setLastSize (hs[2]);
00781 m_sidebars[2]->setLastSize (vs[0]);
00782 m_sidebars[3]->setLastSize (vs[2]);
00783
00784 m_hSplitter->setSizes(hs);
00785 m_vSplitter->setSizes(vs);
00786
00787 setToolViewStyle( (KMultiTabBar::KMultiTabBarStyle)m_restoreConfig->readNumEntry ("Kate-MDI-Sidebar-Style", (int)toolViewStyle()) );
00788 }
00789
00790 void MainWindow::finishRestore ()
00791 {
00792 if (!m_restoreConfig)
00793 return;
00794
00795 if (m_restoreConfig->hasGroup (m_restoreGroup))
00796 {
00797
00798 applyMainWindowSettings(m_restoreConfig, m_restoreGroup);
00799
00800
00801 m_restoreConfig->setGroup (m_restoreGroup);
00802 for ( unsigned int i=0; i < m_toolviews.size(); ++i )
00803 {
00804 KMultiTabBar::KMultiTabBarPosition newPos = (KMultiTabBar::KMultiTabBarPosition) m_restoreConfig->readNumEntry (QString ("Kate-MDI-ToolView-%1-Position").arg(m_toolviews[i]->id), m_toolviews[i]->sidebar()->sidebarPosition());
00805
00806 if (m_toolviews[i]->sidebar()->sidebarPosition() != newPos)
00807 {
00808 moveToolView (m_toolviews[i], newPos);
00809 }
00810 }
00811
00812
00813 m_restoreConfig->setGroup (m_restoreGroup);
00814 for (unsigned int i=0; i < 4; ++i)
00815 m_sidebars[i]->restoreSession (m_restoreConfig);
00816 }
00817
00818
00819 m_restoreConfig = 0;
00820 m_restoreGroup = "";
00821 }
00822
00823 void MainWindow::saveSession (KConfig *config, const QString &group)
00824 {
00825 if (!config)
00826 return;
00827
00828 saveMainWindowSettings (config, group);
00829
00830 config->setGroup (group);
00831
00832
00833 QValueList<int> hs = m_hSplitter->sizes();
00834 QValueList<int> vs = m_vSplitter->sizes();
00835
00836 if (hs[0] <= 2 && !m_sidebars[0]->splitterVisible ())
00837 hs[0] = m_sidebars[0]->lastSize();
00838 if (hs[2] <= 2 && !m_sidebars[1]->splitterVisible ())
00839 hs[2] = m_sidebars[1]->lastSize();
00840 if (vs[0] <= 2 && !m_sidebars[2]->splitterVisible ())
00841 vs[0] = m_sidebars[2]->lastSize();
00842 if (vs[2] <= 2 && !m_sidebars[3]->splitterVisible ())
00843 vs[2] = m_sidebars[3]->lastSize();
00844
00845 config->writeEntry ("Kate-MDI-H-Splitter", hs);
00846 config->writeEntry ("Kate-MDI-V-Splitter", vs);
00847
00848
00849 config->writeEntry ("Kate-MDI-Sidebar-Style", (int)toolViewStyle());
00850
00851
00852 for (unsigned int i=0; i < 4; ++i)
00853 m_sidebars[i]->saveSession (config);
00854 }
00855
00856
00857
00858 }
00859
00860 #include "katemdi.moc"
00861