You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
617 lines
18 KiB
617 lines
18 KiB
15 years ago
|
/*
|
||
|
* Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
|
||
|
*
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License version 2, as published by the Free Software Foundation.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc.,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
14 years ago
|
#include <tqapplication.h>
|
||
|
#include <tqdockarea.h>
|
||
13 years ago
|
#include <tqdockwindow.h>
|
||
14 years ago
|
#include <tqdict.h>
|
||
|
#include <tqwidget.h>
|
||
|
#include <tqobject.h>
|
||
|
#include <tqevent.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeparts/event.h>
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
12 years ago
|
#include <tdepopupmenu.h>
|
||
|
#include <tdeaction.h>
|
||
|
#include <tdeactionclasses.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
|
#include <tdeglobal.h>
|
||
15 years ago
|
|
||
|
#include <KoView.h>
|
||
|
#include <KoMainWindow.h>
|
||
|
|
||
|
#include <kopalette.h>
|
||
|
#include <kotabpalette.h>
|
||
|
#include <kotoolboxpalette.h>
|
||
|
|
||
|
#include <kopalettemanager.h>
|
||
|
|
||
|
|
||
12 years ago
|
KoPaletteManager::KoPaletteManager(KoView * view, TDEActionCollection *ac, const char * name)
|
||
14 years ago
|
: TQObject(view, name)
|
||
15 years ago
|
{
|
||
|
|
||
|
m_view = view;
|
||
|
m_view->installEventFilter(this);
|
||
|
m_actionCollection = ac;
|
||
|
|
||
12 years ago
|
m_actions = new TQDict<TDEToggleAction>();
|
||
14 years ago
|
m_widgets = new TQDict<TQWidget>();
|
||
|
m_palettes = new TQDict<KoPalette>();
|
||
15 years ago
|
m_palettes->setAutoDelete(true);
|
||
14 years ago
|
m_defaultMapping = new TQMap<TQString, TQString>();
|
||
|
m_currentMapping = new TQMap<TQString, TQString>();
|
||
15 years ago
|
m_fixedWidth = 0;
|
||
|
m_setFixedWidth = false;
|
||
|
|
||
14 years ago
|
m_widgetNames = new TQStringList();
|
||
15 years ago
|
|
||
14 years ago
|
m_mapper = new TQSignalMapper(this);
|
||
|
connect(m_mapper, TQT_SIGNAL(mapped(int)), this, TQT_SLOT(slotTogglePalette(int)));
|
||
12 years ago
|
m_viewActionMenu = new TDEActionMenu(i18n("Palettes"), m_actionCollection, "view_palette_action_menu");
|
||
15 years ago
|
|
||
12 years ago
|
TDEConfig * cfg = TDEGlobal::config();
|
||
15 years ago
|
cfg->setGroup("palettes");
|
||
|
|
||
|
bool palettesShown = cfg->readBoolEntry("palettesshown", true);
|
||
12 years ago
|
TDEToggleAction * m_toggleShowHidePalettes;
|
||
15 years ago
|
|
||
|
if ( palettesShown) {
|
||
12 years ago
|
m_toggleShowHidePalettes = new TDEToggleAction(i18n("Hide All Palette Windows"),
|
||
15 years ago
|
"CTRL+SHIFT+H", this,
|
||
14 years ago
|
TQT_SLOT(slotToggleAllPalettes()),
|
||
15 years ago
|
m_actionCollection, "toggleAllPaletteWindows");
|
||
|
|
||
|
m_toggleShowHidePalettes->setCheckedState(i18n("Show Palette Windows Again"));
|
||
|
}
|
||
|
else {
|
||
12 years ago
|
m_toggleShowHidePalettes = new TDEToggleAction(i18n("Show Palette Windows Again"),
|
||
15 years ago
|
"CTRL+SHIFT+H", this,
|
||
14 years ago
|
TQT_SLOT(slotToggleAllPalettes()),
|
||
15 years ago
|
m_actionCollection, "toggleAllPaletteWindows");
|
||
|
|
||
|
m_toggleShowHidePalettes->setCheckedState(i18n("Hide All Palette Windows"));
|
||
|
}
|
||
|
m_viewActionMenu->insert(m_toggleShowHidePalettes);
|
||
|
|
||
|
// Recreate the palettes in the saved order
|
||
14 years ago
|
TQStringList paletteList = TQStringList::split(",", cfg->readEntry("palettes"));
|
||
|
TQStringList::iterator it;
|
||
15 years ago
|
for (it = paletteList.begin(); it != paletteList.end(); ++it) {
|
||
|
if (cfg->hasGroup("palette-" + (*it))) {
|
||
|
|
||
|
cfg->setGroup("palette-" + (*it));
|
||
|
|
||
|
enumKoPaletteStyle style = (enumKoPaletteStyle)cfg->readNumEntry("style", 0);
|
||
14 years ago
|
TQString caption = cfg->readEntry("caption", "");
|
||
15 years ago
|
|
||
|
createPalette((*it), caption, style);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/*
|
||
12 years ago
|
TDEAction * a = new TDEAction(i18n("Restore Palettes"),
|
||
15 years ago
|
0, this,
|
||
14 years ago
|
TQT_SLOT(slotReset()),
|
||
15 years ago
|
this, "restorePalettes");
|
||
|
m_viewActionMenu->insert(a);
|
||
|
*/
|
||
|
m_viewActionMenu->popupMenu()->insertSeparator();
|
||
|
}
|
||
|
|
||
|
|
||
|
KoPaletteManager::~KoPaletteManager()
|
||
|
{
|
||
|
save();
|
||
|
|
||
|
delete m_viewActionMenu;
|
||
|
delete m_widgetNames;
|
||
|
delete m_widgets;
|
||
|
delete m_palettes;
|
||
|
delete m_actions;
|
||
|
delete m_mapper;
|
||
|
delete m_defaultMapping;
|
||
|
delete m_currentMapping;
|
||
|
}
|
||
|
|
||
14 years ago
|
void KoPaletteManager::addWidget(TQWidget * widget,
|
||
|
const TQString & name,
|
||
|
const TQString & paletteName,
|
||
15 years ago
|
int position,
|
||
|
enumKoPaletteStyle style,
|
||
|
bool shown)
|
||
|
{
|
||
|
|
||
|
if (!widget) return;
|
||
|
|
||
14 years ago
|
TQString pname = paletteName;
|
||
15 years ago
|
|
||
14 years ago
|
TQWidget * w = m_widgets->find(name);
|
||
15 years ago
|
if (w != 0 )
|
||
|
{
|
||
|
removeWidget(name);
|
||
|
}
|
||
|
|
||
|
bool visible = true;
|
||
|
|
||
12 years ago
|
TDEConfig * cfg = TDEGlobal::config();
|
||
15 years ago
|
if (cfg->hasGroup("palettetab-" + name)) {
|
||
|
cfg->setGroup("palettetab-" + name);
|
||
|
|
||
|
pname = cfg->readEntry("docker");
|
||
|
visible = cfg->readBoolEntry("visible");
|
||
|
}
|
||
|
|
||
14 years ago
|
KoPalette * palette = m_palettes->find(pname);
|
||
15 years ago
|
|
||
|
if (palette == 0) {
|
||
|
palette = createPalette(pname, widget->caption(), style);
|
||
14 years ago
|
m_defaultPaletteOrder.append(pname+ "," + TQString::number(style));
|
||
15 years ago
|
}
|
||
|
|
||
12 years ago
|
TDEToggleAction * a;
|
||
|
a = new TDEToggleAction(i18n("Show %1").arg(widget->caption()), 0, m_mapper, TQT_SLOT(map()), m_actionCollection);
|
||
13 years ago
|
a->setCheckedState(i18n("Hide %1").arg(widget->caption()));
|
||
15 years ago
|
|
||
|
m_mapper->setMapping(a, m_widgetNames->count()); // This is the position at which we'll insert the action
|
||
|
m_actions->insert( name, a );
|
||
|
m_viewActionMenu->insert(a);
|
||
|
|
||
|
palette->plug(widget, name, position);
|
||
|
|
||
|
m_widgets->insert(name, widget);
|
||
|
|
||
|
// Default mappings ready for restoring
|
||
|
m_defaultMapping->insert(name, pname);
|
||
|
m_defaultWidgetOrder.append(name);
|
||
|
|
||
|
// Find out the hidden state
|
||
14 years ago
|
if(m_widgetNames->contains(name))
|
||
15 years ago
|
{
|
||
|
|
||
|
// The widget has already been added (and removed) during this session
|
||
14 years ago
|
if(m_hiddenWidgets.contains(name))
|
||
15 years ago
|
palette->hidePage( widget );
|
||
|
else
|
||
|
{
|
||
|
a->setChecked(true);
|
||
|
palette->showPage( widget );
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
cfg->setGroup("palettes");
|
||
|
if( cfg->readBoolEntry("palettesshown", shown))
|
||
|
{
|
||
|
if (visible)
|
||
|
{
|
||
|
a->setChecked(true);
|
||
|
palette->showPage( widget );
|
||
|
}
|
||
|
else
|
||
|
palette->hidePage( widget );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (visible)
|
||
|
m_hiddenWidgets.push(name);
|
||
|
palette->hidePage( widget );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Fill the current mappings
|
||
|
m_widgetNames->append(name);
|
||
|
m_currentMapping->insert(name, pname);
|
||
|
}
|
||
|
|
||
|
|
||
|
void KoPaletteManager::slotReset()
|
||
|
{
|
||
|
// Clear all old palettes
|
||
|
m_palettes->setAutoDelete( true );
|
||
|
m_palettes->clear();
|
||
|
|
||
|
m_widgetNames->clear();
|
||
|
|
||
|
// Recreate the palettewindows in the saved order
|
||
14 years ago
|
TQStringList::iterator it;
|
||
15 years ago
|
for (it = m_defaultPaletteOrder.begin(); it != m_defaultPaletteOrder.end(); ++it) {
|
||
14 years ago
|
TQString s = *it;
|
||
|
TQString pname = s.section( ",", 0, 0 );;
|
||
15 years ago
|
enumKoPaletteStyle style = (enumKoPaletteStyle)s.section(",", 1,1).toInt();
|
||
|
createPalette(pname, "", style);
|
||
|
}
|
||
|
|
||
|
// Place all existing (that we didn't throw away!) tabs in the right palette and in the right order
|
||
|
for (it = m_defaultWidgetOrder.begin(); it != m_defaultWidgetOrder.end(); ++it) {
|
||
|
|
||
14 years ago
|
TQString widgetName = *it;
|
||
14 years ago
|
TQWidget * w = m_widgets->find(widgetName);
|
||
15 years ago
|
|
||
|
if (!w) {
|
||
|
continue;
|
||
|
}
|
||
14 years ago
|
TQString paletteName = *m_defaultMapping->find(widgetName);
|
||
|
KoPalette * p = m_palettes->find(paletteName);
|
||
15 years ago
|
|
||
|
if (p == 0) {
|
||
|
// Funny -- we should have a consistent set of palettes without holes!
|
||
|
createPalette(paletteName, "", PALETTE_DOCKER);
|
||
|
}
|
||
|
|
||
|
p->plug(w, widgetName, -1); // XXX: This is not good: we should add it in the same place as originally placed
|
||
|
m_widgetNames->append(widgetName);
|
||
|
m_currentMapping->insert(widgetName, paletteName);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KoPaletteManager::slotResetFont()
|
||
|
{
|
||
14 years ago
|
TQDictIterator<KoPalette> it(*m_palettes);
|
||
15 years ago
|
for (; it.current(); ++it) {
|
||
|
it.current()->resetFont();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
14 years ago
|
TQWidget * KoPaletteManager::widget(const TQString & name)
|
||
15 years ago
|
{
|
||
14 years ago
|
return m_widgets->find(name);
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void KoPaletteManager::showWidget(const TQString & name)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQWidget * w = m_widgets->find(name);
|
||
15 years ago
|
if (!w) return;
|
||
|
|
||
14 years ago
|
TQString pname = *m_currentMapping->find(name);
|
||
15 years ago
|
if (pname.isNull()) return;
|
||
|
|
||
14 years ago
|
KoPalette * p = m_palettes->find(pname);
|
||
15 years ago
|
p->showPage(w);
|
||
|
|
||
12 years ago
|
TDEToggleAction * a = m_actions->find(name);
|
||
15 years ago
|
a->setChecked(true);
|
||
|
}
|
||
|
|
||
14 years ago
|
void KoPaletteManager::hideWidget(const TQString & name)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQWidget * w = m_widgets->find(name);
|
||
15 years ago
|
if (!w) return;
|
||
|
|
||
14 years ago
|
TQString pname = *m_currentMapping->find(name);
|
||
15 years ago
|
if (pname.isNull()) return;
|
||
|
|
||
14 years ago
|
KoPalette * p = m_palettes->find(pname);
|
||
15 years ago
|
p->hidePage(w);
|
||
|
|
||
12 years ago
|
TDEToggleAction * a = m_actions->find(name);
|
||
15 years ago
|
a->setChecked(false);
|
||
|
}
|
||
|
|
||
14 years ago
|
void KoPaletteManager::removeWidget(const TQString & name)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQString palette = *(m_currentMapping->find(name));
|
||
15 years ago
|
if (palette.isNull()) return;
|
||
|
|
||
14 years ago
|
TQWidget * w = m_widgets->find(name);
|
||
15 years ago
|
if (!w) return;
|
||
|
|
||
14 years ago
|
KoPalette * p = m_palettes->find(palette);
|
||
15 years ago
|
if (!p) return;
|
||
|
|
||
|
p->showPage(w);
|
||
|
p->unplug(w);
|
||
|
m_widgets->remove(name);
|
||
|
m_currentMapping->remove(name);
|
||
|
|
||
12 years ago
|
TDEAction * a = m_actions->take(name);
|
||
15 years ago
|
m_viewActionMenu->remove(a);
|
||
|
m_actionCollection->remove(a);
|
||
|
}
|
||
|
|
||
14 years ago
|
KoPalette * KoPaletteManager::createPalette(const TQString & name, const TQString & caption, enumKoPaletteStyle style)
|
||
15 years ago
|
{
|
||
|
Q_ASSERT(m_view);
|
||
|
KoPalette * palette = 0;
|
||
|
|
||
|
|
||
14 years ago
|
palette = m_palettes->find(name);
|
||
15 years ago
|
if (palette) return palette;
|
||
|
|
||
|
|
||
|
switch (style) {
|
||
|
case (PALETTE_DOCKER):
|
||
|
palette = new KoTabPalette(m_view, name.latin1());
|
||
|
break;
|
||
|
case (PALETTE_TOOLBOX):
|
||
|
palette = new KoToolBoxPalette(m_view, name.latin1());
|
||
|
break;
|
||
|
default:
|
||
|
// This is a custom palette that we cannot create
|
||
|
return 0;
|
||
|
};
|
||
|
|
||
|
if(!palette) return 0;
|
||
|
|
||
|
if (m_setFixedWidth)
|
||
|
palette->setFixedWidth(m_fixedWidth);
|
||
|
|
||
|
palette->setCaption(caption);
|
||
|
m_palettes->insert(name, palette);
|
||
|
placePalette(name);
|
||
|
|
||
|
return palette;
|
||
|
}
|
||
|
|
||
14 years ago
|
void KoPaletteManager::placePalette(const TQString & name, TQt::Dock location)
|
||
15 years ago
|
{
|
||
|
Q_ASSERT(!name.isNull());
|
||
14 years ago
|
KoPalette * palette = m_palettes->find(name);
|
||
15 years ago
|
|
||
|
if (!palette) return;
|
||
|
|
||
|
//XXX: Check whether this name occurs in the config list, retrieve the location, set the location
|
||
12 years ago
|
TDEConfig * cfg = TDEGlobal::config();
|
||
15 years ago
|
|
||
|
if (cfg->hasGroup("palette-" + name)) {
|
||
|
cfg->setGroup("palette-" + name);
|
||
14 years ago
|
TQString dockarea = cfg->readEntry("dockarea", "right");
|
||
|
TQString caption = cfg->readEntry("caption", "");
|
||
15 years ago
|
int height = cfg->readNumEntry("height", 120);
|
||
|
int place = cfg->readNumEntry("place", 0);
|
||
|
int width = cfg->readNumEntry("width", 200);
|
||
|
int x = cfg->readNumEntry("x", 0);
|
||
|
int y = cfg->readNumEntry("y", 0);
|
||
|
int offset = cfg->readNumEntry("offset", 0);
|
||
|
palette->setGeometry(x, y, width, height);
|
||
|
palette->setOffset(offset);
|
||
|
if (dockarea == "left" && place == 0) {
|
||
14 years ago
|
location = TQt::DockLeft;
|
||
15 years ago
|
}
|
||
|
else if (dockarea == "right" && place == 0) {
|
||
14 years ago
|
location = TQt::DockRight;
|
||
15 years ago
|
}
|
||
|
else {
|
||
|
location = DockTornOff;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
cfg->setGroup("");
|
||
|
m_dockability = (enumKoDockability) cfg->readNumEntry("palettesdockability");
|
||
|
|
||
|
// Top and bottom will never accept docks
|
||
|
m_view->mainWindow()->topDock()->setAcceptDockWindow(palette, false);
|
||
|
m_view->mainWindow()->bottomDock()->setAcceptDockWindow(palette, false);
|
||
|
|
||
|
// Left and right may accept docks. The height of the screen is important
|
||
14 years ago
|
int h = tqApp->desktop()->height();
|
||
15 years ago
|
switch (m_dockability) {
|
||
|
case (DOCK_ENABLED):
|
||
|
m_view->mainWindow()->leftDock()->setAcceptDockWindow(palette, true);
|
||
|
m_view->mainWindow()->rightDock()->setAcceptDockWindow(palette, true);
|
||
|
m_view->mainWindow()->addDockWindow(palette, location);
|
||
|
break;
|
||
|
case (DOCK_DISABLED):
|
||
|
m_view->mainWindow()->leftDock()->setAcceptDockWindow(palette, false);
|
||
|
m_view->mainWindow()->rightDock()->setAcceptDockWindow(palette, false);
|
||
14 years ago
|
m_view->mainWindow()->addDockWindow(palette, TQt::DockTornOff);
|
||
15 years ago
|
break;
|
||
|
case (DOCK_SMART):
|
||
|
if (h > 768) {
|
||
|
m_view->mainWindow()->leftDock()->setAcceptDockWindow(palette, true);
|
||
|
m_view->mainWindow()->rightDock()->setAcceptDockWindow(palette, true);
|
||
|
m_view->mainWindow()->addDockWindow(palette, location);
|
||
|
}
|
||
|
else {
|
||
|
m_view->mainWindow()->leftDock()->setAcceptDockWindow(palette, false);
|
||
|
m_view->mainWindow()->rightDock()->setAcceptDockWindow(palette, false);
|
||
14 years ago
|
m_view->mainWindow()->addDockWindow(palette, TQt::DockTornOff);
|
||
15 years ago
|
}
|
||
|
break;
|
||
|
};
|
||
|
m_view->mainWindow()->lineUpDockWindows();
|
||
|
}
|
||
|
|
||
14 years ago
|
void KoPaletteManager::addPalette(KoPalette * palette, const TQString & name, TQt::Dock location)
|
||
15 years ago
|
{
|
||
|
Q_ASSERT(palette);
|
||
|
Q_ASSERT(!name.isNull());
|
||
|
|
||
|
m_palettes->insert(name, palette);
|
||
|
placePalette(name, location);
|
||
|
}
|
||
|
|
||
|
void KoPaletteManager::slotTogglePalette(int paletteIndex)
|
||
|
{
|
||
|
// Toggle the right palette
|
||
14 years ago
|
TQString name = *m_widgetNames->at(paletteIndex);
|
||
14 years ago
|
TQWidget * w = m_widgets->find(name);
|
||
|
TQString pname = *m_currentMapping->find(name);
|
||
|
KoPalette * p = m_palettes->find(pname);
|
||
15 years ago
|
p->togglePageHidden( w );
|
||
|
|
||
|
m_hiddenWidgets.clear();
|
||
|
}
|
||
|
|
||
|
void KoPaletteManager::slotToggleAllPalettes()
|
||
|
{
|
||
|
if( ! m_hiddenWidgets.isEmpty())
|
||
|
{
|
||
|
// Restore previous visibility state
|
||
|
while(!m_hiddenWidgets.isEmpty())
|
||
|
{
|
||
14 years ago
|
TQString name = m_hiddenWidgets.pop();
|
||
14 years ago
|
TQWidget *w = m_widgets->find(name);
|
||
12 years ago
|
TDEToggleAction * a = m_actions->find(name);
|
||
15 years ago
|
a->setChecked(true);
|
||
|
|
||
14 years ago
|
TQString pname = *m_currentMapping->find(name);
|
||
|
KoPalette * p = m_palettes->find(pname);
|
||
15 years ago
|
p->showPage(w);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// Save hidden state and hide all palettes
|
||
|
m_hiddenWidgets.clear();
|
||
14 years ago
|
TQDictIterator<TQWidget> it(*m_widgets);
|
||
15 years ago
|
for (; it.current(); ++it)
|
||
|
{
|
||
12 years ago
|
TDEToggleAction * a = m_actions->find(it.currentKey());
|
||
15 years ago
|
if(a->isChecked())
|
||
|
{
|
||
|
a->setChecked(false);
|
||
|
m_hiddenWidgets.push(it.currentKey());
|
||
|
|
||
14 years ago
|
TQString pname = *m_currentMapping->find(it.currentKey());
|
||
|
KoPalette * p = m_palettes->find(pname);
|
||
15 years ago
|
p->hidePage(it.current());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KoPaletteManager::showAllPalettes(bool shown)
|
||
|
{
|
||
14 years ago
|
TQDictIterator<KoPalette> it(*m_palettes);
|
||
15 years ago
|
for (; it.current(); ++it) {
|
||
|
it.current()->makeVisible(shown);
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
bool KoPaletteManager::eventFilter( TQObject *o, TQEvent *e )
|
||
15 years ago
|
{
|
||
14 years ago
|
if (TQT_BASE_OBJECT(o) != TQT_BASE_OBJECT(m_view)) return false;
|
||
15 years ago
|
|
||
14 years ago
|
if(e && e->type() == (TQEvent::User + 42)) {
|
||
15 years ago
|
KParts::PartActivateEvent * pae = dynamic_cast<KParts::PartActivateEvent *>(e);
|
||
|
if(pae && pae->widget() && pae->widget() == m_view) {
|
||
|
if (pae->activated()) {
|
||
|
showAllPalettes( true );
|
||
|
}
|
||
|
else {
|
||
|
showAllPalettes( false );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void KoPaletteManager::save()
|
||
|
{
|
||
|
// XXX: Save to the configuration
|
||
|
// We save:
|
||
|
// * which tab at which place in which palette
|
||
|
// * which tab is hidden
|
||
|
// * whether a palette is floating or docked
|
||
|
// * dock location of a docked palette
|
||
|
// * float location of a floated palette
|
||
|
// * order in which the palettes are docked.
|
||
|
|
||
|
if (!m_view) return;
|
||
|
if (!m_view->mainWindow()) return;
|
||
|
|
||
12 years ago
|
TDEConfig * cfg = TDEGlobal::config();
|
||
15 years ago
|
Q_ASSERT(cfg);
|
||
|
cfg->setGroup("");
|
||
|
|
||
14 years ago
|
TQString widgets;
|
||
15 years ago
|
|
||
|
// Save the list of palettes
|
||
14 years ago
|
TQDictIterator<KoPalette> itP(*m_palettes);
|
||
15 years ago
|
|
||
14 years ago
|
TQStringList paletteList;
|
||
15 years ago
|
|
||
|
for (; itP.current(); ++itP) {
|
||
|
|
||
|
KoPalette * p = itP.current();
|
||
|
|
||
|
cfg->setGroup("palette-" + itP.currentKey());
|
||
|
|
||
|
if ( p->area() == m_view->mainWindow()->leftDock() ) {
|
||
|
cfg->writeEntry("dockarea", "left");
|
||
|
}
|
||
|
else {
|
||
|
cfg->writeEntry("dockarea", "right");
|
||
|
}
|
||
|
cfg->writeEntry("place", p->place());
|
||
|
cfg->writeEntry("x", p->x());
|
||
|
cfg->writeEntry("y", p->y());
|
||
|
cfg->writeEntry("height", p->height());
|
||
|
cfg->writeEntry("width", p->width());
|
||
|
cfg->writeEntry("palettestyle", p->style());
|
||
|
cfg->writeEntry("caption", p->caption());
|
||
|
cfg->writeEntry("offset", p->offset());
|
||
|
|
||
|
// XXX: I dare say that it is immediately visible that I never have had
|
||
|
// any formal training in algorithms. BSAR.
|
||
|
if (paletteList.isEmpty()) {
|
||
|
paletteList.append(itP.currentKey());
|
||
|
}
|
||
|
else {
|
||
14 years ago
|
TQStringList::iterator it;
|
||
15 years ago
|
bool inserted = false;
|
||
|
for (it = paletteList.begin(); it != paletteList.end(); ++it) {
|
||
14 years ago
|
KoPalette * p2 = m_palettes->find((*it));
|
||
15 years ago
|
if (p2->y() > p->y()) {
|
||
|
paletteList.insert(it, itP.currentKey());
|
||
|
inserted = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (!inserted) {
|
||
|
paletteList.append(itP.currentKey());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
cfg->setGroup("palettes");
|
||
|
|
||
|
cfg->writeEntry("palettes", paletteList.join(","));
|
||
|
bool palettesShown = m_hiddenWidgets.isEmpty();
|
||
|
cfg->writeEntry("palettesshown", palettesShown);
|
||
|
|
||
14 years ago
|
TQDictIterator<TQWidget> itW(*m_widgets);
|
||
15 years ago
|
for (; itW.current(); ++itW) {
|
||
|
cfg->setGroup("palettetab-" + itW.currentKey());
|
||
14 years ago
|
TQString pname = *m_currentMapping->find(itW.currentKey());
|
||
|
KoPalette * p = m_palettes->find(pname);
|
||
14 years ago
|
TQWidget * w = itW.current();
|
||
15 years ago
|
cfg->writeEntry("docker", pname);
|
||
|
|
||
|
if(palettesShown)
|
||
|
cfg->writeEntry("visible", !p->isHidden(w));
|
||
|
else
|
||
14 years ago
|
if(m_hiddenWidgets.contains(itW.currentKey()))
|
||
15 years ago
|
cfg->writeEntry("visible", true);
|
||
|
else
|
||
|
cfg->writeEntry("visible", false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KoPaletteManager::setFixedWidth(int w)
|
||
|
{
|
||
|
m_fixedWidth = w;
|
||
|
m_setFixedWidth = true;
|
||
|
}
|
||
|
|
||
|
#include "kopalettemanager.moc"
|