~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/marquis/marquis.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// marquis.cpp
 
2
//
 
3
// Copyright (C) 2000 Neil Stevens <multivac@fcmail.com>
 
4
//
 
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
6
// of this software and associated documentation files (the "Software"), to deal
 
7
// in the Software without restriction, including without limitation the rights
 
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
9
// copies of the Software, and to permit persons to whom the Software is
 
10
// furnished to do so, subject to the following conditions:
 
11
// 
 
12
// The above copyright notice and this permission notice shall be included in
 
13
// all copies or substantial portions of the Software.
 
14
// 
 
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
18
// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
19
// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
20
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
21
// 
 
22
// Except as contained in this notice, the name(s) of the author(s) shall not be
 
23
// used in advertising or otherwise to promote the sale, use or other dealings
 
24
// in this Software without prior written authorization from the author(s).
 
25
 
 
26
#ifdef HAVE_CONFIG_H
 
27
#include <config.h>
 
28
#endif
 
29
 
 
30
#include <kconfig.h>
 
31
#include <kdebug.h>
 
32
#include "pluginloader.h"
 
33
#include "marquis.h"
 
34
#include "player.h"
 
35
 
 
36
Marquis::Marquis()
 
37
        : KMainWindow()
 
38
        , SessionManagement()
 
39
{
 
40
        NOATUNPLUGINC(Marquis);
 
41
        hide();
 
42
        kdDebug() << "number of members == " << memberList->count() << endl;
 
43
}
 
44
 
 
45
Marquis::~Marquis()
 
46
{
 
47
}
 
48
 
 
49
void Marquis::restore(void)
 
50
{
 
51
        KConfig *config = kapp->sessionConfig();
 
52
        kdDebug() << "Marquis::restore()" << endl;
 
53
        readGlobalProperties(config);
 
54
        config->setGroup(QString::fromLatin1("Number"));
 
55
        config->writeEntry(QString::fromLatin1("NumberOfWindows"), 1);
 
56
}
 
57
 
 
58
// unload every window, and save ihe config a QStringList of those loaded
 
59
void Marquis::saveGlobalProperties(KConfig *c)
 
60
{
 
61
        kdDebug() << "Marquis::saveGlobalProperties()" << endl;
 
62
        // borrowed from Plugin config dialog
 
63
        QStringList specList;
 
64
        QValueList<NoatunLibraryInfo> loaded = napp->libraryLoader()->loaded();
 
65
        for( QValueList<NoatunLibraryInfo>::Iterator i = loaded.begin(); i != loaded.end(); ++i)
 
66
        {
 
67
                if(!specList.contains((*i).specfile)
 
68
                   && napp->libraryLoader()->isLoaded((*i).specfile)
 
69
                   && (*i).specfile != "marquis.plugin")
 
70
                {
 
71
                        specList += (*i).specfile;
 
72
                        napp->libraryLoader()->remove((*i).specfile);
 
73
                }
 
74
        }
 
75
        c->writeEntry("Loaded Plugins", specList);
 
76
        c->writeEntry("Volume", napp->player()->volume());
 
77
}
 
78
 
 
79
// get the list of loaded plugins from the config, and load them
 
80
void Marquis::readGlobalProperties(KConfig *c)
 
81
{
 
82
        c->setGroup(QString::null);
 
83
        QStringList list = c->readListEntry("Loaded Plugins");
 
84
 
 
85
        kdDebug() << "Marquis::readGlobalProperties()" << endl;
 
86
        for(QStringList::ConstIterator i=list.begin(); i!=list.end(); ++i)
 
87
                kdDebug() << *i << endl;
 
88
        kdDebug() << "Marquis::readGlobalProperties() there we go" << endl;
 
89
 
 
90
        napp->libraryLoader()->loadAll(list);
 
91
 
 
92
        napp->player()->setVolume( c->readNumEntry("Volume", 100) );
 
93
}
 
94
 
 
95
#include "marquis.moc"