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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
/***************************************************************************
* Copyright (C) 2004 by Antonio Fasolato *
* Antonio.Fasolato@poste.it *
* *
* 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. *
***************************************************************************/
#include "potracegui.h"
#include "mainwidget.h"
#include <tqlabel.h>
#include <tqclipboard.h>
#include <kmainwindow.h>
#include <klocale.h>
#include <kstatusbar.h>
#include <ktoolbar.h>
#include <kmenubar.h>
#include <kpopupmenu.h>
#include <kstdaccel.h>
#include <kaction.h>
#include <kstdaction.h>
#include <tdeio/netaccess.h>
#include <kimageio.h>
#include <kkeydialog.h>
#include <kedittoolbar.h>
#include <kmessagebox.h>
potracegui::potracegui()
: KMainWindow( 0, "potracegui" ), m_centralWidget(new MainWidget(this))
{
// set the shell's ui resource file
setXMLFile("potraceguiui.rc");
KImageIO::registerFormats();
setCentralWidget(m_centralWidget);
setAcceptDrops(true);
statusBar()->show();
statusBar()->message(i18n("Welcome to PotraceGui 1.3"));
setAutoSaveSettings();
setAcceptDrops(true);
connect(m_centralWidget,TQT_SIGNAL(signalChangeStatusbar(TQString)),this,TQT_SLOT(changeStatusbar(TQString)));
createInterface();
}
potracegui::~potracegui()
{
}
void potracegui::createInterface()
{
/*handled by potracegui*/
KStdAction::openNew(TQT_TQOBJECT(this), TQT_SLOT(fileNew()),actionCollection());
KStdAction::quit(TQT_TQOBJECT(this), TQT_SLOT(quit()),actionCollection());
m_toolbarAction=KStdAction::showToolbar(TQT_TQOBJECT(this), TQT_SLOT(showToolbar()),actionCollection());
m_statusbarAction=KStdAction::showStatusbar(TQT_TQOBJECT(this), TQT_SLOT(showStatusbar()),actionCollection());
KStdAction::keyBindings(TQT_TQOBJECT(this), TQT_SLOT(configureKeys()),actionCollection());
KStdAction::configureToolbars(TQT_TQOBJECT(this), TQT_SLOT(configureTB()),actionCollection());
/*handled by MainWidget*/
KStdAction::open(TQT_TQOBJECT(m_centralWidget), TQT_SLOT(fileOpen()),actionCollection());
KStdAction::save(TQT_TQOBJECT(m_centralWidget), TQT_SLOT(fileSave()),actionCollection());
KStdAction::saveAs(TQT_TQOBJECT(m_centralWidget), TQT_SLOT(fileSaveAs()),actionCollection());
KStdAction::close(TQT_TQOBJECT(m_centralWidget), TQT_SLOT(fileClose()),actionCollection());
KStdAction::cut(TQT_TQOBJECT(m_centralWidget), TQT_SLOT(cut()),actionCollection());
KStdAction::copy(TQT_TQOBJECT(m_centralWidget), TQT_SLOT(copy()),actionCollection());
KStdAction::paste(TQT_TQOBJECT(m_centralWidget), TQT_SLOT(paste()),actionCollection());
/*Create menu and toolbar*/
createGUI();
}
//MENU ACTIONS
void potracegui::fileNew()
{
(new potracegui)->show();
}
void potracegui::quit()
{
close();
}
void potracegui::showToolbar()
{
if(m_toolbarAction->isChecked())
toolBar()->show();
else
toolBar()->hide();
}
void potracegui::showStatusbar()
{
if(m_statusbarAction->isChecked())
statusBar()->show();
else
statusBar()->hide();
}
void potracegui::configureKeys()
{
KKeyDialog::configure(actionCollection(),"potraceguiui.rc");
}
void potracegui::configureTB()
{
KEditToolbar dlg(actionCollection());
connect(&dlg,TQT_SIGNAL(newToolbarConfig()),this,TQT_SLOT(NewTBConfig()));
dlg.exec();
}
void potracegui::NewTBConfig()
{
createGUI();
saveMainWindowSettings(TDEGlobal::config());
}
void potracegui::changeStatusbar(TQString message)
{
statusBar()->message(message);
}
bool potracegui::queryClose() {
if(m_centralWidget->m_changed) {
int res= KMessageBox::warningYesNoCancel(this, i18n("Save changes?"));
if(res==KMessageBox::Yes) {
m_centralWidget->fileSave();
return true;
}
else if(res==KMessageBox::Cancel) {
return false;
}
if(res==KMessageBox::No) {
return true;
}
}
return true;
}
#include "potracegui.moc"
|