blob: 3ef0bf9a1ddda26c691399024afbbe06fdc0db7a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/***************************************************************************
* Copyright (C) 2003 by S�astien Laot *
* slaout@linux62.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tdeglobal.h>
#include <kstandarddirs.h>
#include <tqstring.h>
#include <tdeaction.h>
#include <tdeapplication.h>
#include <tdemainwindow.h>
#include <tqdir.h>
#include <kdebug.h>
#include <tdeconfig.h>
#include "global.h"
#include "bnpview.h"
#include "settings.h"
/** Define initial values for global variables : */
TQString Global::s_customSavesFolder = "";
LikeBack *Global::likeBack = 0L;
DebugWindow *Global::debugWindow = 0L;
BackgroundManager *Global::backgroundManager = 0L;
SystemTray *Global::systemTray = 0L;
BNPView *Global::bnpView = 0L;
TDEGlobalAccel *Global::globalAccel = 0L;
TDEConfig *Global::basketConfig = 0L;
AboutData Global::basketAbout;
void Global::setCustomSavesFolder(const TQString &folder)
{
s_customSavesFolder = folder;
}
#include <iostream>
TQString Global::savesFolder()
{
static TQString *folder = 0L; // Memorize the folder to do not have to re-compute it each time it's needed
if (folder == 0L) { // Initialize it if not yet done
if (!s_customSavesFolder.isEmpty()) { // Passed by command line (for development & debug purpose)
TQDir dir;
dir.mkdir(s_customSavesFolder);
folder = new TQString(s_customSavesFolder.endsWith("/") ? s_customSavesFolder : s_customSavesFolder + "/");
} else if (!Settings::dataFolder().isEmpty()) { // Set by config option (in Basket -> Backup & Restore)
TQDir dir;
dir.mkdir(s_customSavesFolder);
folder = new TQString(Settings::dataFolder().endsWith("/") ? Settings::dataFolder() : Settings::dataFolder() + "/");
} else { // The default path (should be that for most computers)
folder = new TQString(TDEGlobal::dirs()->saveLocation("data", "basket/"));
}
}
return *folder;
}
TQString Global::basketsFolder() { return savesFolder() + "baskets/"; }
TQString Global::backgroundsFolder() { return savesFolder() + "backgrounds/"; }
TQString Global::templatesFolder() { return savesFolder() + "templates/"; }
TQString Global::tempCutFolder() { return savesFolder() + "temp-cut/"; }
TQString Global::openNoteIcon() // FIXME: Now an edit icon
{
return Global::bnpView->m_actEditNote->icon();
}
TDEMainWindow* Global::mainWindow()
{
TQWidget* res = kapp->mainWidget();
if(res && res->inherits("TDEMainWindow"))
{
return static_cast<TDEMainWindow*>(res);
}
return 0;
}
TDEConfig* Global::config()
{
if(!Global::basketConfig)
Global::basketConfig = TDESharedConfig::openConfig("basketrc");
return Global::basketConfig;
}
|