Changeset View
Changeset View
Standalone View
Standalone View
src/kgraphviewer.cpp
Show All 10 Lines | 1 | /* This file is part of KGraphViewer. | |||
---|---|---|---|---|---|
11 | General Public License for more details. | 11 | General Public License for more details. | ||
12 | 12 | | |||
13 | You should have received a copy of the GNU General Public License | 13 | You should have received a copy of the GNU General Public License | ||
14 | along with this program; if not, write to the Free Software | 14 | along with this program; if not, write to the Free Software | ||
15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
16 | 02110-1301, USA | 16 | 02110-1301, USA | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | | ||||
20 | #include "kgraphviewer.h" | 19 | #include "kgraphviewer.h" | ||
21 | #include "kgraphviewer_debug.h" | | |||
22 | #include "part/kgraphviewer_interface.h" | | |||
23 | #include "kgraphviewerConfigDialog.h" | 20 | #include "kgraphviewerConfigDialog.h" | ||
21 | #include "kgraphviewer_debug.h" | ||||
24 | #include "kgraphviewersettings.h" | 22 | #include "kgraphviewersettings.h" | ||
23 | #include "part/kgraphviewer_interface.h" | ||||
24 | #include "ui_preferencesOpenInExistingWindow.h" | ||||
25 | #include "ui_preferencesParsing.h" | 25 | #include "ui_preferencesParsing.h" | ||
26 | #include "ui_preferencesReload.h" | 26 | #include "ui_preferencesReload.h" | ||
27 | #include "ui_preferencesOpenInExistingWindow.h" | | |||
28 | #include "ui_preferencesReopenPreviouslyOpenedFiles.h" | 27 | #include "ui_preferencesReopenPreviouslyOpenedFiles.h" | ||
29 | 28 | | |||
30 | #include <kshortcutsdialog.h> | 29 | #include <KActionCollection> | ||
31 | #include <QFileDialog> | 30 | #include <KColorScheme> | ||
32 | #include <kconfig.h> | 31 | #include <KParts/ReadOnlyPart> | ||
33 | #include <QUrl> | 32 | #include <KPluginFactory> | ||
34 | #include <QTabWidget> | 33 | #include <KService> | ||
35 | #include <kparts/partmanager.h> | 34 | #include <QDBusConnection> | ||
36 | #include <kedittoolbar.h> | | |||
37 | #include <QDebug> | 35 | #include <QDebug> | ||
36 | #include <QFileDialog> | ||||
37 | #include <QIcon> | ||||
38 | #include <QStandardPaths> | 38 | #include <QStandardPaths> | ||
39 | #include <kstandardaction.h> | | |||
40 | #include <ktoggleaction.h> | | |||
41 | #include <KService> | | |||
42 | #include <KPluginFactory> | | |||
43 | #include <kmessagebox.h> | | |||
44 | #include <QStatusBar> | 39 | #include <QStatusBar> | ||
40 | #include <QTabWidget> | ||||
41 | #include <QUrl> | ||||
42 | #include <iostream> | ||||
43 | #include <kconfig.h> | ||||
45 | #include <kconfigdialog.h> | 44 | #include <kconfigdialog.h> | ||
46 | #include <QIcon> | 45 | #include <kedittoolbar.h> | ||
46 | #include <klocalizedstring.h> | ||||
47 | #include <kmessagebox.h> | ||||
48 | #include <kparts/partmanager.h> | ||||
47 | #include <krecentfilesaction.h> | 49 | #include <krecentfilesaction.h> | ||
50 | #include <kshortcutsdialog.h> | ||||
51 | #include <kstandardaction.h> | ||||
52 | #include <ktoggleaction.h> | ||||
48 | #include <ktoolbar.h> | 53 | #include <ktoolbar.h> | ||
49 | #include <KActionCollection> | | |||
50 | #include <klocalizedstring.h> | | |||
51 | #include <QDBusConnection> | | |||
52 | #include <KParts/ReadOnlyPart> | | |||
53 | #include <iostream> | | |||
54 | #include <stdio.h> | 54 | #include <stdio.h> | ||
55 | #include <stdlib.h> | 55 | #include <stdlib.h> | ||
56 | #include <KColorScheme> | | |||
57 | 56 | | |||
58 | KGraphViewerWindow::KGraphViewerWindow() | 57 | KGraphViewerWindow::KGraphViewerWindow() | ||
59 | : KParts::MainWindow(), | 58 | : KParts::MainWindow() | ||
60 | m_rfa(nullptr) | 59 | , m_rfa(nullptr) | ||
61 | { | 60 | { | ||
62 | // set the shell's ui resource file | 61 | // set the shell's ui resource file | ||
63 | setXMLFile("kgraphviewerui.rc"); | 62 | setXMLFile("kgraphviewerui.rc"); | ||
64 | 63 | | |||
65 | // std::cerr << "Creating tab widget" << std::endl; | 64 | // std::cerr << "Creating tab widget" << std::endl; | ||
66 | m_widget = new QTabWidget(this); | 65 | m_widget = new QTabWidget(this); | ||
67 | m_widget->setTabsClosable(true); | 66 | m_widget->setTabsClosable(true); | ||
68 | connect(m_widget, &QTabWidget::tabCloseRequested, | 67 | connect(m_widget, &QTabWidget::tabCloseRequested, this, static_cast<void (KGraphViewerWindow::*)(int)>(&KGraphViewerWindow::close)); | ||
69 | this, static_cast<void(KGraphViewerWindow::*)(int)>(&KGraphViewerWindow::close)); | 68 | connect(m_widget, &QTabWidget::currentChanged, this, &KGraphViewerWindow::newTabSelectedSlot); | ||
70 | connect(m_widget, &QTabWidget::currentChanged, | | |||
71 | this, &KGraphViewerWindow::newTabSelectedSlot); | | |||
72 | 69 | | |||
73 | setCentralWidget(m_widget); | 70 | setCentralWidget(m_widget); | ||
74 | 71 | | |||
75 | if (QDBusConnection::sessionBus().registerService( "org.kde.kgraphviewer" )) | 72 | if (QDBusConnection::sessionBus().registerService("org.kde.kgraphviewer")) { | ||
76 | { | | |||
77 | qCDebug(KGRAPHVIEWER_LOG) << "Service Registered successfully"; | 73 | qCDebug(KGRAPHVIEWER_LOG) << "Service Registered successfully"; | ||
78 | QDBusConnection::sessionBus().registerObject("/", this, QDBusConnection::ExportAllSlots); | 74 | QDBusConnection::sessionBus().registerObject("/", this, QDBusConnection::ExportAllSlots); | ||
79 | 75 | | |||
80 | } | 76 | } else { | ||
81 | else | | |||
82 | { | | |||
83 | qCDebug(KGRAPHVIEWER_LOG) << "Failed to register service..."; | 77 | qCDebug(KGRAPHVIEWER_LOG) << "Failed to register service..."; | ||
84 | } | 78 | } | ||
85 | 79 | | |||
86 | // this routine will find and load our Part. it finds the Part by | 80 | // this routine will find and load our Part. it finds the Part by | ||
87 | // name which is a bad idea usually.. but it's alright in this | 81 | // name which is a bad idea usually.. but it's alright in this | ||
88 | // case since our Part is made for this Shell | 82 | // case since our Part is made for this Shell | ||
89 | 83 | | |||
90 | // Create a KParts part manager, to handle part activation/deactivation | 84 | // Create a KParts part manager, to handle part activation/deactivation | ||
91 | m_manager = new KParts::PartManager( this ); | 85 | m_manager = new KParts::PartManager(this); | ||
92 | 86 | | |||
93 | // When the manager says the active part changes, the window updates (recreates) the GUI | 87 | // When the manager says the active part changes, the window updates (recreates) the GUI | ||
94 | connect(m_manager, &KParts::PartManager::activePartChanged, | 88 | connect(m_manager, &KParts::PartManager::activePartChanged, this, &KGraphViewerWindow::createGUI); | ||
95 | this, &KGraphViewerWindow::createGUI); | | |||
96 | 89 | | |||
97 | setupGUI(ToolBar | Keys | StatusBar | Save); | 90 | setupGUI(ToolBar | Keys | StatusBar | Save); | ||
98 | 91 | | |||
99 | // then, setup our actions | 92 | // then, setup our actions | ||
100 | setupActions(); | 93 | setupActions(); | ||
101 | 94 | | |||
102 | // Creates the GUI with a null part to make appear the main app menus and tools | 95 | // Creates the GUI with a null part to make appear the main app menus and tools | ||
103 | createGUI(nullptr); | 96 | createGUI(nullptr); | ||
104 | } | 97 | } | ||
105 | 98 | | |||
106 | KGraphViewerWindow::~KGraphViewerWindow() | 99 | KGraphViewerWindow::~KGraphViewerWindow() | ||
107 | { | 100 | { | ||
108 | KSharedConfig::Ptr config = KSharedConfig::openConfig(); | 101 | KSharedConfig::Ptr config = KSharedConfig::openConfig(); | ||
109 | if (m_rfa) | 102 | if (m_rfa) | ||
110 | m_rfa->saveEntries(KConfigGroup(config, "kgraphviewer recent files")); | 103 | m_rfa->saveEntries(KConfigGroup(config, "kgraphviewer recent files")); | ||
111 | 104 | | |||
112 | // delete partsmanager explicitly, to avoid activePartChanged being emitted from here | 105 | // delete partsmanager explicitly, to avoid activePartChanged being emitted from here | ||
113 | delete m_manager; | 106 | delete m_manager; | ||
114 | } | 107 | } | ||
115 | 108 | | |||
116 | void KGraphViewerWindow::reloadPreviousFiles() | 109 | void KGraphViewerWindow::reloadPreviousFiles() | ||
117 | { | 110 | { | ||
118 | QStringList previouslyOpenedFiles = KGraphViewerSettings::previouslyOpenedFiles(); | 111 | QStringList previouslyOpenedFiles = KGraphViewerSettings::previouslyOpenedFiles(); | ||
119 | if ( (previouslyOpenedFiles.empty() == false) | 112 | if ((previouslyOpenedFiles.empty() == false) && | ||
120 | && (KMessageBox::questionYesNo(this, | 113 | (KMessageBox::questionYesNo(this, i18n("Do you want to reload files from the previous session?"), i18n("Session Restore"), KStandardGuiItem::yes(), KStandardGuiItem::no(), "reopenPreviouslyOpenedFilesMode") == KMessageBox::Yes)) { | ||
121 | i18n("Do you want to reload files from the previous session?"), | | |||
122 | i18n("Session Restore"), | | |||
123 | KStandardGuiItem::yes(), | | |||
124 | KStandardGuiItem::no(), | | |||
125 | "reopenPreviouslyOpenedFilesMode" ) == KMessageBox::Yes) ) | | |||
126 | { | | |||
127 | QStringList::const_iterator it, it_end; | 114 | QStringList::const_iterator it, it_end; | ||
128 | it = previouslyOpenedFiles.constBegin(); it_end = previouslyOpenedFiles.constEnd(); | 115 | it = previouslyOpenedFiles.constBegin(); | ||
129 | for (; it != it_end; it++) | 116 | it_end = previouslyOpenedFiles.constEnd(); | ||
130 | { | 117 | for (; it != it_end; it++) { | ||
131 | openUrl(*it); | 118 | openUrl(*it); | ||
132 | } | 119 | } | ||
133 | KGraphViewerSettings::self()->save(); | 120 | KGraphViewerSettings::self()->save(); | ||
134 | } | 121 | } | ||
135 | | ||||
136 | } | 122 | } | ||
137 | 123 | | |||
138 | void KGraphViewerWindow::openUrl(const QUrl& url) | 124 | void KGraphViewerWindow::openUrl(const QUrl &url) | ||
139 | { | 125 | { | ||
140 | qCDebug(KGRAPHVIEWER_LOG) << url; | 126 | qCDebug(KGRAPHVIEWER_LOG) << url; | ||
141 | KPluginFactory *factory = KPluginLoader("kgraphviewerpart").factory(); | 127 | KPluginFactory *factory = KPluginLoader("kgraphviewerpart").factory(); | ||
142 | if (!factory) | 128 | if (!factory) { | ||
143 | { | | |||
144 | // if we couldn't find our Part, we exit since the Shell by | 129 | // if we couldn't find our Part, we exit since the Shell by | ||
145 | // itself can't do anything useful | 130 | // itself can't do anything useful | ||
146 | KMessageBox::error(this, i18n("Could not find the KGraphViewer part.")); | 131 | KMessageBox::error(this, i18n("Could not find the KGraphViewer part.")); | ||
147 | qApp->quit(); | 132 | qApp->quit(); | ||
148 | // we return here, cause kapp->quit() only means "exit the | 133 | // we return here, cause kapp->quit() only means "exit the | ||
149 | // next time we enter the event loop... | 134 | // next time we enter the event loop... | ||
150 | return; | 135 | return; | ||
151 | } | 136 | } | ||
152 | KParts::ReadOnlyPart* part = factory->create<KParts::ReadOnlyPart>(this); | 137 | KParts::ReadOnlyPart *part = factory->create<KParts::ReadOnlyPart>(this); | ||
153 | KGraphViewer::KGraphViewerInterface* kgv = qobject_cast<KGraphViewer::KGraphViewerInterface*>( part ); | 138 | KGraphViewer::KGraphViewerInterface *kgv = qobject_cast<KGraphViewer::KGraphViewerInterface *>(part); | ||
154 | if( ! kgv ) | 139 | if (!kgv) { | ||
155 | { | | |||
156 | // This should not happen | 140 | // This should not happen | ||
157 | qCWarning(KGRAPHVIEWER_LOG) << "Failed to get KPart" << endl; | 141 | qCWarning(KGRAPHVIEWER_LOG) << "Failed to get KPart" << endl; | ||
158 | return; | 142 | return; | ||
159 | } | 143 | } | ||
160 | kgv->setBackgroundColor(KGraphViewerSettings::backgroundColor()); | 144 | kgv->setBackgroundColor(KGraphViewerSettings::backgroundColor()); | ||
161 | (KGraphViewerSettings::parsingMode() == "external") | 145 | (KGraphViewerSettings::parsingMode() == "external") ? kgv->setLayoutMethod(KGraphViewer::KGraphViewerInterface::ExternalProgram) : kgv->setLayoutMethod(KGraphViewer::KGraphViewerInterface::InternalLibrary); | ||
162 | ?kgv->setLayoutMethod(KGraphViewer::KGraphViewerInterface::ExternalProgram) | | |||
163 | :kgv->setLayoutMethod(KGraphViewer::KGraphViewerInterface::InternalLibrary); | | |||
164 | 146 | | |||
165 | if (part) | 147 | if (part) { | ||
166 | { | | |||
167 | QString fileName = url.url(); | 148 | QString fileName = url.url(); | ||
168 | QWidget *w = part->widget(); | 149 | QWidget *w = part->widget(); | ||
169 | 150 | | |||
170 | part->openUrl( url ); | 151 | part->openUrl(url); | ||
171 | 152 | | |||
172 | if (m_rfa) | 153 | if (m_rfa) { | ||
173 | { | | |||
174 | m_rfa->addUrl(url); | 154 | m_rfa->addUrl(url); | ||
175 | KSharedConfig::Ptr config = KSharedConfig::openConfig(); | 155 | KSharedConfig::Ptr config = KSharedConfig::openConfig(); | ||
176 | m_rfa->saveEntries(KConfigGroup(config, "kgraphviewer recent files")); | 156 | m_rfa->saveEntries(KConfigGroup(config, "kgraphviewer recent files")); | ||
177 | } | 157 | } | ||
178 | 158 | | |||
179 | m_openedFiles.push_back(fileName); | 159 | m_openedFiles.push_back(fileName); | ||
180 | m_tabsPartsMap[w] = part; | 160 | m_tabsPartsMap[w] = part; | ||
181 | m_tabsFilesMap[w] = fileName; | 161 | m_tabsFilesMap[w] = fileName; | ||
182 | connect(this,SIGNAL(hide(KParts::Part*)),part,SLOT(slotHide(KParts::Part*))); | 162 | connect(this, SIGNAL(hide(KParts::Part *)), part, SLOT(slotHide(KParts::Part *))); | ||
183 | 163 | | |||
184 | connect(part, SIGNAL(hoverEnter(QString)), | 164 | connect(part, SIGNAL(hoverEnter(QString)), this, SLOT(slotHoverEnter(QString))); | ||
185 | this, SLOT(slotHoverEnter(QString))); | 165 | connect(part, SIGNAL(hoverLeave(QString)), this, SLOT(slotHoverLeave(QString))); | ||
186 | connect(part, SIGNAL(hoverLeave(QString)), | | |||
187 | this, SLOT(slotHoverLeave(QString))); | | |||
188 | 166 | | |||
189 | m_manager->addPart( part, true ); | 167 | m_manager->addPart(part, true); | ||
190 | const QString label = fileName.section('/', -1, -1); | 168 | const QString label = fileName.section('/', -1, -1); | ||
191 | m_widget->addTab(w, QIcon::fromTheme("kgraphviewer"), label); | 169 | m_widget->addTab(w, QIcon::fromTheme("kgraphviewer"), label); | ||
192 | m_widget->setCurrentWidget(w); | 170 | m_widget->setCurrentWidget(w); | ||
193 | m_closeAction->setEnabled(true); | 171 | m_closeAction->setEnabled(true); | ||
194 | } | 172 | } | ||
195 | } | 173 | } | ||
196 | 174 | | |||
197 | void KGraphViewerWindow::fileOpen() | 175 | void KGraphViewerWindow::fileOpen() | ||
198 | { | 176 | { | ||
199 | qCDebug(KGRAPHVIEWER_LOG) ; | 177 | qCDebug(KGRAPHVIEWER_LOG); | ||
200 | // this slot is called whenever the File->Open menu is selected, | 178 | // this slot is called whenever the File->Open menu is selected, | ||
201 | // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar | 179 | // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar | ||
202 | // button is clicked | 180 | // button is clicked | ||
203 | QFileDialog fileDialog(this); | 181 | QFileDialog fileDialog(this); | ||
204 | fileDialog.setMimeTypeFilters(QStringList(QStringLiteral("text/vnd.graphviz"))); | 182 | fileDialog.setMimeTypeFilters(QStringList(QStringLiteral("text/vnd.graphviz"))); | ||
205 | fileDialog.setAcceptMode(QFileDialog::AcceptOpen); | 183 | fileDialog.setAcceptMode(QFileDialog::AcceptOpen); | ||
206 | fileDialog.setFileMode(QFileDialog::ExistingFiles); | 184 | fileDialog.setFileMode(QFileDialog::ExistingFiles); | ||
207 | if (fileDialog.exec() != QFileDialog::Accepted) { | 185 | if (fileDialog.exec() != QFileDialog::Accepted) { | ||
208 | return; | 186 | return; | ||
209 | } | 187 | } | ||
210 | 188 | | |||
211 | foreach (const QUrl& url, fileDialog.selectedUrls()) { | 189 | foreach (const QUrl &url, fileDialog.selectedUrls()) { | ||
212 | openUrl(url); | 190 | openUrl(url); | ||
213 | } | 191 | } | ||
214 | } | 192 | } | ||
215 | 193 | | |||
216 | void KGraphViewerWindow::setupActions() | 194 | void KGraphViewerWindow::setupActions() | ||
217 | { | 195 | { | ||
218 | // create our actions | 196 | // create our actions | ||
219 | QAction* newAction = actionCollection()->addAction( KStandardAction::New, "file_new", this, SLOT(fileNew()) ); | 197 | QAction *newAction = actionCollection()->addAction(KStandardAction::New, "file_new", this, SLOT(fileNew())); | ||
220 | newAction->setWhatsThis(i18n("Opens a new empty KGraphViewer window.")); | 198 | newAction->setWhatsThis(i18n("Opens a new empty KGraphViewer window.")); | ||
221 | 199 | | |||
222 | QAction* openAction = actionCollection()->addAction( KStandardAction::Open, "file_open", this, SLOT(fileOpen()) ); | 200 | QAction *openAction = actionCollection()->addAction(KStandardAction::Open, "file_open", this, SLOT(fileOpen())); | ||
223 | openAction->setWhatsThis(i18n("Shows the file open dialog to choose a Graphviz DOT file to open.")); | 201 | openAction->setWhatsThis(i18n("Shows the file open dialog to choose a Graphviz DOT file to open.")); | ||
224 | 202 | | |||
225 | m_rfa = KStandardAction::openRecent(this, SLOT(slotURLSelected(QUrl)), this); | 203 | m_rfa = KStandardAction::openRecent(this, SLOT(slotURLSelected(QUrl)), this); | ||
226 | actionCollection()->addAction(m_rfa->objectName(),m_rfa); | 204 | actionCollection()->addAction(m_rfa->objectName(), m_rfa); | ||
227 | m_rfa->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again.")); | 205 | m_rfa->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again.")); | ||
228 | 206 | | |||
229 | KSharedConfig::Ptr config = KSharedConfig::openConfig(); | 207 | KSharedConfig::Ptr config = KSharedConfig::openConfig(); | ||
230 | m_rfa->loadEntries(KConfigGroup(config, "kgraphviewer recent files")); | 208 | m_rfa->loadEntries(KConfigGroup(config, "kgraphviewer recent files")); | ||
231 | 209 | | |||
232 | m_closeAction = actionCollection()->addAction( KStandardAction::Close, "file_close", this, SLOT(close()) ); | 210 | m_closeAction = actionCollection()->addAction(KStandardAction::Close, "file_close", this, SLOT(close())); | ||
233 | m_closeAction->setWhatsThis(i18n("Closes the current file")); | 211 | m_closeAction->setWhatsThis(i18n("Closes the current file")); | ||
234 | m_closeAction->setEnabled(false); | 212 | m_closeAction->setEnabled(false); | ||
235 | 213 | | |||
236 | QAction* quitAction = actionCollection()->addAction( KStandardAction::Quit, "file_quit", qApp, SLOT(quit()) ); | 214 | QAction *quitAction = actionCollection()->addAction(KStandardAction::Quit, "file_quit", qApp, SLOT(quit())); | ||
237 | quitAction->setWhatsThis(i18n("Quits KGraphViewer.")); | 215 | quitAction->setWhatsThis(i18n("Quits KGraphViewer.")); | ||
238 | 216 | | |||
239 | m_statusbarAction = KStandardAction::showStatusbar(this, SLOT(optionsShowStatusbar()), this); | 217 | m_statusbarAction = KStandardAction::showStatusbar(this, SLOT(optionsShowStatusbar()), this); | ||
240 | m_statusbarAction->setWhatsThis(i18n("Shows or hides the status bar.")); | 218 | m_statusbarAction->setWhatsThis(i18n("Shows or hides the status bar.")); | ||
241 | 219 | | |||
242 | QAction* kbAction = actionCollection()->addAction( KStandardAction::KeyBindings, "options_configure_keybinding", this, SLOT(optionsConfigureKeys()) ); | 220 | QAction *kbAction = actionCollection()->addAction(KStandardAction::KeyBindings, "options_configure_keybinding", this, SLOT(optionsConfigureKeys())); | ||
243 | kbAction->setWhatsThis(i18n("Configure the bindings between keys and actions.")); | 221 | kbAction->setWhatsThis(i18n("Configure the bindings between keys and actions.")); | ||
244 | 222 | | |||
245 | QAction* ctAction = actionCollection()->addAction( KStandardAction::ConfigureToolbars, "options_configure_toolbars", this, SLOT(optionsConfigureToolbars()) ); | 223 | QAction *ctAction = actionCollection()->addAction(KStandardAction::ConfigureToolbars, "options_configure_toolbars", this, SLOT(optionsConfigureToolbars())); | ||
246 | ctAction->setWhatsThis(i18n("Toolbar configuration.")); | 224 | ctAction->setWhatsThis(i18n("Toolbar configuration.")); | ||
247 | 225 | | |||
248 | QAction* configureAction = actionCollection()->addAction( KStandardAction::Preferences, "options_configure", this, SLOT(optionsConfigure()) ); | 226 | QAction *configureAction = actionCollection()->addAction(KStandardAction::Preferences, "options_configure", this, SLOT(optionsConfigure())); | ||
249 | configureAction->setWhatsThis(i18n("Main KGraphViewer configuration options.")); | 227 | configureAction->setWhatsThis(i18n("Main KGraphViewer configuration options.")); | ||
250 | } | 228 | } | ||
251 | 229 | | |||
252 | void KGraphViewerWindow::closeEvent(QCloseEvent* event) | 230 | void KGraphViewerWindow::closeEvent(QCloseEvent *event) | ||
253 | { | 231 | { | ||
254 | KGraphViewerSettings::setPreviouslyOpenedFiles(m_openedFiles); | 232 | KGraphViewerSettings::setPreviouslyOpenedFiles(m_openedFiles); | ||
255 | KGraphViewerSettings::self()->save(); | 233 | KGraphViewerSettings::self()->save(); | ||
256 | KParts::MainWindow::closeEvent(event); | 234 | KParts::MainWindow::closeEvent(event); | ||
257 | } | 235 | } | ||
258 | 236 | | |||
259 | void KGraphViewerWindow::fileNew() | 237 | void KGraphViewerWindow::fileNew() | ||
260 | { | 238 | { | ||
261 | // this slot is called whenever the File->New menu is selected, | 239 | // this slot is called whenever the File->New menu is selected, | ||
262 | // the New shortcut is pressed (usually CTRL+N) or the New toolbar | 240 | // the New shortcut is pressed (usually CTRL+N) or the New toolbar | ||
263 | // button is clicked | 241 | // button is clicked | ||
264 | 242 | | |||
265 | (new KGraphViewerWindow())->show(); | 243 | (new KGraphViewerWindow())->show(); | ||
266 | } | 244 | } | ||
267 | 245 | | |||
268 | | ||||
269 | void KGraphViewerWindow::optionsShowToolbar() | 246 | void KGraphViewerWindow::optionsShowToolbar() | ||
270 | { | 247 | { | ||
271 | // this is all very cut and paste code for showing/hiding the | 248 | // this is all very cut and paste code for showing/hiding the | ||
272 | // toolbar | 249 | // toolbar | ||
273 | if (m_toolbarAction->isChecked()) | 250 | if (m_toolbarAction->isChecked()) | ||
274 | toolBar()->show(); | 251 | toolBar()->show(); | ||
275 | else | 252 | else | ||
276 | toolBar()->hide(); | 253 | toolBar()->hide(); | ||
Show All 16 Lines | |||||
293 | 270 | | |||
294 | void KGraphViewerWindow::optionsConfigureToolbars() | 271 | void KGraphViewerWindow::optionsConfigureToolbars() | ||
295 | { | 272 | { | ||
296 | KConfigGroup group(KConfigGroup(KSharedConfig::openConfig(), "kgraphviewer")); | 273 | KConfigGroup group(KConfigGroup(KSharedConfig::openConfig(), "kgraphviewer")); | ||
297 | KMainWindow::saveMainWindowSettings(group); | 274 | KMainWindow::saveMainWindowSettings(group); | ||
298 | 275 | | |||
299 | // use the standard toolbar editor | 276 | // use the standard toolbar editor | ||
300 | KEditToolBar dlg(factory()); | 277 | KEditToolBar dlg(factory()); | ||
301 | connect(&dlg, &KEditToolBar::newToolbarConfig, | 278 | connect(&dlg, &KEditToolBar::newToolbarConfig, this, &KGraphViewerWindow::applyNewToolbarConfig); | ||
302 | this, &KGraphViewerWindow::applyNewToolbarConfig); | | |||
303 | dlg.exec(); | 279 | dlg.exec(); | ||
304 | } | 280 | } | ||
305 | 281 | | |||
306 | void KGraphViewerWindow::optionsConfigure() | 282 | void KGraphViewerWindow::optionsConfigure() | ||
307 | { | 283 | { | ||
308 | //An instance of your dialog could be already created and could be cached, | 284 | // An instance of your dialog could be already created and could be cached, | ||
309 | //in which case you want to display the cached dialog instead of creating | 285 | // in which case you want to display the cached dialog instead of creating | ||
310 | //another one | 286 | // another one | ||
311 | if ( KgvConfigurationDialog::showDialog( "settings" ) ) | 287 | if (KgvConfigurationDialog::showDialog("settings")) | ||
312 | return; | 288 | return; | ||
313 | 289 | | |||
314 | //KConfigDialog didn't find an instance of this dialog, so lets create it : | 290 | // KConfigDialog didn't find an instance of this dialog, so lets create it : | ||
315 | KgvConfigurationDialog* dialog = new KgvConfigurationDialog( this, "settings", KGraphViewerSettings::self()); | 291 | KgvConfigurationDialog *dialog = new KgvConfigurationDialog(this, "settings", KGraphViewerSettings::self()); | ||
316 | connect(dialog, &KgvConfigurationDialog::backgroundColorChanged, | 292 | connect(dialog, &KgvConfigurationDialog::backgroundColorChanged, this, &KGraphViewerWindow::slotBackgroundColorChanged); | ||
317 | this, &KGraphViewerWindow::slotBackgroundColorChanged); | | |||
318 | Ui::KGraphViewerPreferencesParsingWidget* parsingWidget = dialog->parsingWidget; | 293 | Ui::KGraphViewerPreferencesParsingWidget *parsingWidget = dialog->parsingWidget; | ||
319 | qCDebug(KGRAPHVIEWER_LOG) << KGraphViewerSettings::parsingMode(); | 294 | qCDebug(KGRAPHVIEWER_LOG) << KGraphViewerSettings::parsingMode(); | ||
320 | if (KGraphViewerSettings::parsingMode() == "external") | 295 | if (KGraphViewerSettings::parsingMode() == "external") { | ||
321 | { | | |||
322 | parsingWidget->external->setChecked(true); | 296 | parsingWidget->external->setChecked(true); | ||
323 | } | 297 | } else if (KGraphViewerSettings::parsingMode() == "internal") { | ||
324 | else if (KGraphViewerSettings::parsingMode() == "internal") | | |||
325 | { | | |||
326 | parsingWidget->internal->setChecked(true); | 298 | parsingWidget->internal->setChecked(true); | ||
327 | } | 299 | } | ||
328 | connect(parsingWidget->external, &QRadioButton::toggled, | 300 | connect(parsingWidget->external, &QRadioButton::toggled, this, &KGraphViewerWindow::slotParsingModeExternalToggled); | ||
329 | this, &KGraphViewerWindow::slotParsingModeExternalToggled); | 301 | connect(parsingWidget->internal, &QRadioButton::toggled, this, &KGraphViewerWindow::slotParsingModeInternalToggled); | ||
330 | connect(parsingWidget->internal, &QRadioButton::toggled, | | |||
331 | this, &KGraphViewerWindow::slotParsingModeInternalToggled); | | |||
332 | 302 | | |||
333 | Ui::KGraphViewerPreferencesReloadWidget* reloadWidget = dialog->reloadWidget; | 303 | Ui::KGraphViewerPreferencesReloadWidget *reloadWidget = dialog->reloadWidget; | ||
334 | qCDebug(KGRAPHVIEWER_LOG) << KGraphViewerSettings::reloadOnChangeMode(); | 304 | qCDebug(KGRAPHVIEWER_LOG) << KGraphViewerSettings::reloadOnChangeMode(); | ||
335 | if (KGraphViewerSettings::reloadOnChangeMode() == "true") | 305 | if (KGraphViewerSettings::reloadOnChangeMode() == "true") { | ||
336 | { | | |||
337 | reloadWidget->yes->setChecked(true); | 306 | reloadWidget->yes->setChecked(true); | ||
338 | } | 307 | } else if (KGraphViewerSettings::reloadOnChangeMode() == "false") { | ||
339 | else if (KGraphViewerSettings::reloadOnChangeMode() == "false") | | |||
340 | { | | |||
341 | reloadWidget->no->setChecked(true); | 308 | reloadWidget->no->setChecked(true); | ||
342 | } | 309 | } else // if (KGraphViewerSettings::reloadOnChangeMode() == "ask") | ||
343 | else // if (KGraphViewerSettings::reloadOnChangeMode() == "ask") | | |||
344 | { | 310 | { | ||
345 | reloadWidget->ask->setChecked(true); | 311 | reloadWidget->ask->setChecked(true); | ||
346 | } | 312 | } | ||
347 | 313 | | |||
348 | connect(reloadWidget->yes, &QRadioButton::toggled, | 314 | connect(reloadWidget->yes, &QRadioButton::toggled, this, &KGraphViewerWindow::slotReloadOnChangeModeYesToggled); | ||
349 | this, &KGraphViewerWindow::slotReloadOnChangeModeYesToggled); | 315 | connect(reloadWidget->no, &QRadioButton::toggled, this, &KGraphViewerWindow::slotReloadOnChangeModeNoToggled); | ||
350 | connect(reloadWidget->no, &QRadioButton::toggled, | 316 | connect(reloadWidget->ask, &QRadioButton::toggled, this, &KGraphViewerWindow::slotReloadOnChangeModeAskToggled); | ||
351 | this, &KGraphViewerWindow::slotReloadOnChangeModeNoToggled); | | |||
352 | connect(reloadWidget->ask, &QRadioButton::toggled, | | |||
353 | this, &KGraphViewerWindow::slotReloadOnChangeModeAskToggled); | | |||
354 | 317 | | |||
355 | Ui::KGraphViewerPreferencesOpenInExistingWindowWidget* openingWidget = dialog->openingWidget; | 318 | Ui::KGraphViewerPreferencesOpenInExistingWindowWidget *openingWidget = dialog->openingWidget; | ||
356 | if (KGraphViewerSettings::openInExistingWindowMode() == "true") | 319 | if (KGraphViewerSettings::openInExistingWindowMode() == "true") { | ||
357 | { | | |||
358 | openingWidget->yes->setChecked(true); | 320 | openingWidget->yes->setChecked(true); | ||
359 | } | 321 | } else if (KGraphViewerSettings::openInExistingWindowMode() == "false") { | ||
360 | else if (KGraphViewerSettings::openInExistingWindowMode() == "false") | | |||
361 | { | | |||
362 | openingWidget->no->setChecked(true); | 322 | openingWidget->no->setChecked(true); | ||
363 | } | 323 | } else // if (KGraphViewerSettings::openInExistingWindowMode() == "ask") | ||
364 | else // if (KGraphViewerSettings::openInExistingWindowMode() == "ask") | | |||
365 | { | 324 | { | ||
366 | openingWidget->ask->setChecked(true); | 325 | openingWidget->ask->setChecked(true); | ||
367 | } | 326 | } | ||
368 | 327 | | |||
369 | connect(openingWidget->yes, &QRadioButton::toggled, | 328 | connect(openingWidget->yes, &QRadioButton::toggled, this, &KGraphViewerWindow::slotOpenInExistingWindowModeYesToggled); | ||
370 | this, &KGraphViewerWindow::slotOpenInExistingWindowModeYesToggled); | 329 | connect(openingWidget->no, &QRadioButton::toggled, this, &KGraphViewerWindow::slotOpenInExistingWindowModeNoToggled); | ||
371 | connect(openingWidget->no, &QRadioButton::toggled, | 330 | connect(openingWidget->ask, &QRadioButton::toggled, this, &KGraphViewerWindow::slotOpenInExistingWindowModeAskToggled); | ||
372 | this, &KGraphViewerWindow::slotOpenInExistingWindowModeNoToggled); | | |||
373 | connect(openingWidget->ask, &QRadioButton::toggled, | | |||
374 | this, &KGraphViewerWindow::slotOpenInExistingWindowModeAskToggled); | | |||
375 | 331 | | |||
376 | Ui::KGraphViewerPreferencesReopenPreviouslyOpenedFilesWidget* reopeningWidget = dialog->reopeningWidget; | 332 | Ui::KGraphViewerPreferencesReopenPreviouslyOpenedFilesWidget *reopeningWidget = dialog->reopeningWidget; | ||
377 | if (KGraphViewerSettings::reopenPreviouslyOpenedFilesMode() == "true") | 333 | if (KGraphViewerSettings::reopenPreviouslyOpenedFilesMode() == "true") { | ||
378 | { | | |||
379 | reopeningWidget->yes->setChecked(true); | 334 | reopeningWidget->yes->setChecked(true); | ||
380 | } | 335 | } else if (KGraphViewerSettings::reopenPreviouslyOpenedFilesMode() == "false") { | ||
381 | else if (KGraphViewerSettings::reopenPreviouslyOpenedFilesMode() == "false") | | |||
382 | { | | |||
383 | reopeningWidget->no->setChecked(true); | 336 | reopeningWidget->no->setChecked(true); | ||
384 | } | 337 | } else // if (KGraphViewerSettings::reopenPreviouslyOpenedFilesMode() == "ask") | ||
385 | else // if (KGraphViewerSettings::reopenPreviouslyOpenedFilesMode() == "ask") | | |||
386 | { | 338 | { | ||
387 | reopeningWidget->ask->setChecked(true); | 339 | reopeningWidget->ask->setChecked(true); | ||
388 | } | 340 | } | ||
389 | 341 | | |||
390 | connect(reopeningWidget->yes, &QRadioButton::toggled, | 342 | connect(reopeningWidget->yes, &QRadioButton::toggled, this, &KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeYesToggled); | ||
391 | this, &KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeYesToggled); | 343 | connect(reopeningWidget->no, &QRadioButton::toggled, this, &KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeNoToggled); | ||
392 | connect(reopeningWidget->no, &QRadioButton::toggled, | 344 | connect(reopeningWidget->ask, &QRadioButton::toggled, this, &KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeAskToggled); | ||
393 | this, &KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeNoToggled); | | |||
394 | connect(reopeningWidget->ask, &QRadioButton::toggled, | | |||
395 | this, &KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeAskToggled); | | |||
396 | 345 | | |||
397 | dialog->show(); | 346 | dialog->show(); | ||
398 | } | 347 | } | ||
399 | 348 | | |||
400 | void KGraphViewerWindow::applyNewToolbarConfig() | 349 | void KGraphViewerWindow::applyNewToolbarConfig() | ||
401 | { | 350 | { | ||
402 | applyMainWindowSettings(KSharedConfig::openConfig()->group("kgraphviewer")); | 351 | applyMainWindowSettings(KSharedConfig::openConfig()->group("kgraphviewer")); | ||
403 | } | 352 | } | ||
404 | 353 | | |||
405 | void KGraphViewerWindow::slotReloadOnChangeModeYesToggled(bool value) | 354 | void KGraphViewerWindow::slotReloadOnChangeModeYesToggled(bool value) | ||
406 | { | 355 | { | ||
407 | qCDebug(KGRAPHVIEWER_LOG); | 356 | qCDebug(KGRAPHVIEWER_LOG); | ||
408 | if (value) | 357 | if (value) { | ||
409 | { | | |||
410 | KGraphViewerSettings::setReloadOnChangeMode("true"); | 358 | KGraphViewerSettings::setReloadOnChangeMode("true"); | ||
411 | } | 359 | } | ||
412 | // qCDebug(KGRAPHVIEWER_LOG) << "emitting"; | 360 | // qCDebug(KGRAPHVIEWER_LOG) << "emitting"; | ||
413 | // emit(settingsChanged()); | 361 | // emit(settingsChanged()); | ||
414 | KGraphViewerSettings::self()->save(); | 362 | KGraphViewerSettings::self()->save(); | ||
415 | } | 363 | } | ||
416 | 364 | | |||
417 | void KGraphViewerWindow::slotReloadOnChangeModeNoToggled(bool value) | 365 | void KGraphViewerWindow::slotReloadOnChangeModeNoToggled(bool value) | ||
418 | { | 366 | { | ||
419 | qCDebug(KGRAPHVIEWER_LOG); | 367 | qCDebug(KGRAPHVIEWER_LOG); | ||
420 | if (value) | 368 | if (value) { | ||
421 | { | | |||
422 | KGraphViewerSettings::setReloadOnChangeMode("false"); | 369 | KGraphViewerSettings::setReloadOnChangeMode("false"); | ||
423 | } | 370 | } | ||
424 | // qCDebug(KGRAPHVIEWER_LOG) << "emitting"; | 371 | // qCDebug(KGRAPHVIEWER_LOG) << "emitting"; | ||
425 | // emit(settingsChanged()); | 372 | // emit(settingsChanged()); | ||
426 | KGraphViewerSettings::self()->save(); | 373 | KGraphViewerSettings::self()->save(); | ||
427 | } | 374 | } | ||
428 | 375 | | |||
429 | void KGraphViewerWindow::slotReloadOnChangeModeAskToggled(bool value) | 376 | void KGraphViewerWindow::slotReloadOnChangeModeAskToggled(bool value) | ||
430 | { | 377 | { | ||
431 | qCDebug(KGRAPHVIEWER_LOG); | 378 | qCDebug(KGRAPHVIEWER_LOG); | ||
432 | if (value) | 379 | if (value) { | ||
433 | { | | |||
434 | KGraphViewerSettings::setReloadOnChangeMode("ask"); | 380 | KGraphViewerSettings::setReloadOnChangeMode("ask"); | ||
435 | } | 381 | } | ||
436 | // qCDebug(KGRAPHVIEWER_LOG) << "emitting"; | 382 | // qCDebug(KGRAPHVIEWER_LOG) << "emitting"; | ||
437 | // emit(settingsChanged()); | 383 | // emit(settingsChanged()); | ||
438 | KGraphViewerSettings::self()->save(); | 384 | KGraphViewerSettings::self()->save(); | ||
439 | } | 385 | } | ||
440 | 386 | | |||
441 | void KGraphViewerWindow::slotOpenInExistingWindowModeYesToggled(bool value) | 387 | void KGraphViewerWindow::slotOpenInExistingWindowModeYesToggled(bool value) | ||
442 | { | 388 | { | ||
443 | qCDebug(KGRAPHVIEWER_LOG) << value; | 389 | qCDebug(KGRAPHVIEWER_LOG) << value; | ||
444 | if (value) | 390 | if (value) { | ||
445 | { | | |||
446 | KGraphViewerSettings::setOpenInExistingWindowMode("true"); | 391 | KGraphViewerSettings::setOpenInExistingWindowMode("true"); | ||
447 | } | 392 | } | ||
448 | KGraphViewerSettings::self()->save(); | 393 | KGraphViewerSettings::self()->save(); | ||
449 | } | 394 | } | ||
450 | 395 | | |||
451 | void KGraphViewerWindow::slotOpenInExistingWindowModeNoToggled(bool value) | 396 | void KGraphViewerWindow::slotOpenInExistingWindowModeNoToggled(bool value) | ||
452 | { | 397 | { | ||
453 | qCDebug(KGRAPHVIEWER_LOG) << value; | 398 | qCDebug(KGRAPHVIEWER_LOG) << value; | ||
454 | if (value) | 399 | if (value) { | ||
455 | { | | |||
456 | KGraphViewerSettings::setOpenInExistingWindowMode("false"); | 400 | KGraphViewerSettings::setOpenInExistingWindowMode("false"); | ||
457 | } | 401 | } | ||
458 | KGraphViewerSettings::self()->save(); | 402 | KGraphViewerSettings::self()->save(); | ||
459 | } | 403 | } | ||
460 | 404 | | |||
461 | void KGraphViewerWindow::slotOpenInExistingWindowModeAskToggled(bool value) | 405 | void KGraphViewerWindow::slotOpenInExistingWindowModeAskToggled(bool value) | ||
462 | { | 406 | { | ||
463 | qCDebug(KGRAPHVIEWER_LOG) << value; | 407 | qCDebug(KGRAPHVIEWER_LOG) << value; | ||
464 | if (value) | 408 | if (value) { | ||
465 | { | | |||
466 | KGraphViewerSettings::setOpenInExistingWindowMode("ask"); | 409 | KGraphViewerSettings::setOpenInExistingWindowMode("ask"); | ||
467 | } | 410 | } | ||
468 | KGraphViewerSettings::self()->save(); | 411 | KGraphViewerSettings::self()->save(); | ||
469 | } | 412 | } | ||
470 | 413 | | |||
471 | void KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeYesToggled(bool value) | 414 | void KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeYesToggled(bool value) | ||
472 | { | 415 | { | ||
473 | qCDebug(KGRAPHVIEWER_LOG) << value; | 416 | qCDebug(KGRAPHVIEWER_LOG) << value; | ||
474 | if (value) | 417 | if (value) { | ||
475 | { | | |||
476 | KGraphViewerSettings::setReopenPreviouslyOpenedFilesMode("true"); | 418 | KGraphViewerSettings::setReopenPreviouslyOpenedFilesMode("true"); | ||
477 | } | 419 | } | ||
478 | KGraphViewerSettings::self()->save(); | 420 | KGraphViewerSettings::self()->save(); | ||
479 | } | 421 | } | ||
480 | 422 | | |||
481 | void KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeNoToggled(bool value) | 423 | void KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeNoToggled(bool value) | ||
482 | { | 424 | { | ||
483 | qCDebug(KGRAPHVIEWER_LOG) << value; | 425 | qCDebug(KGRAPHVIEWER_LOG) << value; | ||
484 | if (value) | 426 | if (value) { | ||
485 | { | | |||
486 | KGraphViewerSettings::setReopenPreviouslyOpenedFilesMode("false"); | 427 | KGraphViewerSettings::setReopenPreviouslyOpenedFilesMode("false"); | ||
487 | } | 428 | } | ||
488 | KGraphViewerSettings::self()->save(); | 429 | KGraphViewerSettings::self()->save(); | ||
489 | } | 430 | } | ||
490 | 431 | | |||
491 | void KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeAskToggled(bool value) | 432 | void KGraphViewerWindow::slotReopenPreviouslyOpenedFilesModeAskToggled(bool value) | ||
492 | { | 433 | { | ||
493 | qCDebug(KGRAPHVIEWER_LOG) << value; | 434 | qCDebug(KGRAPHVIEWER_LOG) << value; | ||
494 | if (value) | 435 | if (value) { | ||
495 | { | | |||
496 | KGraphViewerSettings::setReopenPreviouslyOpenedFilesMode("ask"); | 436 | KGraphViewerSettings::setReopenPreviouslyOpenedFilesMode("ask"); | ||
497 | } | 437 | } | ||
498 | KGraphViewerSettings::self()->save(); | 438 | KGraphViewerSettings::self()->save(); | ||
499 | } | 439 | } | ||
500 | 440 | | |||
501 | void KGraphViewerWindow::slotParsingModeExternalToggled(bool value) | 441 | void KGraphViewerWindow::slotParsingModeExternalToggled(bool value) | ||
502 | { | 442 | { | ||
503 | qCDebug(KGRAPHVIEWER_LOG); | 443 | qCDebug(KGRAPHVIEWER_LOG); | ||
504 | if (value) | 444 | if (value) { | ||
505 | { | | |||
506 | KGraphViewerSettings::setParsingMode("external"); | 445 | KGraphViewerSettings::setParsingMode("external"); | ||
507 | } | 446 | } | ||
508 | // qCDebug(KGRAPHVIEWER_LOG) << "emitting"; | 447 | // qCDebug(KGRAPHVIEWER_LOG) << "emitting"; | ||
509 | // emit(settingsChanged()); | 448 | // emit(settingsChanged()); | ||
510 | KGraphViewerSettings::self()->save(); | 449 | KGraphViewerSettings::self()->save(); | ||
511 | } | 450 | } | ||
512 | 451 | | |||
513 | void KGraphViewerWindow::slotParsingModeInternalToggled(bool value) | 452 | void KGraphViewerWindow::slotParsingModeInternalToggled(bool value) | ||
514 | { | 453 | { | ||
515 | qCDebug(KGRAPHVIEWER_LOG); | 454 | qCDebug(KGRAPHVIEWER_LOG); | ||
516 | if (value) | 455 | if (value) { | ||
517 | { | | |||
518 | KGraphViewerSettings::setParsingMode("internal"); | 456 | KGraphViewerSettings::setParsingMode("internal"); | ||
519 | } | 457 | } | ||
520 | // qCDebug(KGRAPHVIEWER_LOG) << "emitting"; | 458 | // qCDebug(KGRAPHVIEWER_LOG) << "emitting"; | ||
521 | // emit(settingsChanged()); | 459 | // emit(settingsChanged()); | ||
522 | KGraphViewerSettings::self()->save(); | 460 | KGraphViewerSettings::self()->save(); | ||
523 | } | 461 | } | ||
524 | 462 | | |||
525 | | ||||
526 | | ||||
527 | void KGraphViewerWindow::slotURLSelected(const QUrl& url) | 463 | void KGraphViewerWindow::slotURLSelected(const QUrl &url) | ||
528 | { | 464 | { | ||
529 | openUrl(url); | 465 | openUrl(url); | ||
530 | } | 466 | } | ||
531 | 467 | | |||
532 | void KGraphViewerWindow::close(int index) | 468 | void KGraphViewerWindow::close(int index) | ||
533 | { | 469 | { | ||
534 | QWidget *tab = m_widget->widget(index); | 470 | QWidget *tab = m_widget->widget(index); | ||
535 | m_openedFiles.removeAll(m_tabsFilesMap[tab]); | 471 | m_openedFiles.removeAll(m_tabsFilesMap[tab]); | ||
536 | m_widget->removeTab(index); | 472 | m_widget->removeTab(index); | ||
537 | tab->hide(); | 473 | tab->hide(); | ||
538 | KParts::Part* part = m_tabsPartsMap[tab]; | 474 | KParts::Part *part = m_tabsPartsMap[tab]; | ||
539 | m_manager->removePart(part); | 475 | m_manager->removePart(part); | ||
540 | m_tabsPartsMap.remove(tab); | 476 | m_tabsPartsMap.remove(tab); | ||
541 | m_tabsFilesMap.remove(tab); | 477 | m_tabsFilesMap.remove(tab); | ||
542 | delete part; part = nullptr; | 478 | delete part; | ||
479 | part = nullptr; | ||||
543 | /* delete tab; | 480 | /* delete tab; | ||
544 | tab = nullptr;*/ | 481 | tab = nullptr;*/ | ||
545 | m_closeAction->setEnabled(m_widget->count() > 0); | 482 | m_closeAction->setEnabled(m_widget->count() > 0); | ||
546 | } | 483 | } | ||
547 | 484 | | |||
548 | void KGraphViewerWindow::close() | 485 | void KGraphViewerWindow::close() | ||
549 | { | 486 | { | ||
550 | int currentPage = m_widget->currentIndex(); | 487 | int currentPage = m_widget->currentIndex(); | ||
551 | if (currentPage != -1) | 488 | if (currentPage != -1) { | ||
552 | { | | |||
553 | close(currentPage); | 489 | close(currentPage); | ||
554 | } | 490 | } | ||
555 | } | 491 | } | ||
556 | 492 | | |||
557 | void KGraphViewerWindow::newTabSelectedSlot(int index) | 493 | void KGraphViewerWindow::newTabSelectedSlot(int index) | ||
558 | { | 494 | { | ||
559 | emit(hide((KParts::Part*)(m_manager->activePart()))); | 495 | emit(hide((KParts::Part *)(m_manager->activePart()))); | ||
560 | 496 | | |||
561 | QWidget *tab = m_widget->widget(index); | 497 | QWidget *tab = m_widget->widget(index); | ||
562 | if (tab) { | 498 | if (tab) { | ||
563 | m_manager->setActivePart(m_tabsPartsMap[tab]); | 499 | m_manager->setActivePart(m_tabsPartsMap[tab]); | ||
564 | } | 500 | } | ||
565 | } | 501 | } | ||
566 | 502 | | |||
567 | void KGraphViewerWindow::slotHoverEnter(const QString& id) | 503 | void KGraphViewerWindow::slotHoverEnter(const QString &id) | ||
568 | { | 504 | { | ||
569 | qCDebug(KGRAPHVIEWER_LOG) << id; | 505 | qCDebug(KGRAPHVIEWER_LOG) << id; | ||
570 | statusBar()->showMessage(id); | 506 | statusBar()->showMessage(id); | ||
571 | } | 507 | } | ||
572 | 508 | | |||
573 | void KGraphViewerWindow::slotHoverLeave(const QString& id) | 509 | void KGraphViewerWindow::slotHoverLeave(const QString &id) | ||
574 | { | 510 | { | ||
575 | qCDebug(KGRAPHVIEWER_LOG) << id; | 511 | qCDebug(KGRAPHVIEWER_LOG) << id; | ||
576 | statusBar()->showMessage(""); | 512 | statusBar()->showMessage(""); | ||
577 | } | 513 | } | ||
578 | 514 | | |||
579 | void KGraphViewerWindow::slotBackgroundColorChanged(const QColor&) | 515 | void KGraphViewerWindow::slotBackgroundColorChanged(const QColor &) | ||
580 | { | 516 | { | ||
581 | qCDebug(KGRAPHVIEWER_LOG); | 517 | qCDebug(KGRAPHVIEWER_LOG); | ||
582 | foreach(KParts::Part* part, m_tabsPartsMap) | 518 | foreach (KParts::Part *part, m_tabsPartsMap) { | ||
583 | { | | |||
584 | KGraphViewer::KGraphViewerInterface* kgv = qobject_cast<KGraphViewer::KGraphViewerInterface*>( part ); | 519 | KGraphViewer::KGraphViewerInterface *kgv = qobject_cast<KGraphViewer::KGraphViewerInterface *>(part); | ||
585 | if( ! kgv ) | 520 | if (!kgv) { | ||
586 | { | | |||
587 | // This should not happen | 521 | // This should not happen | ||
588 | return; | 522 | return; | ||
589 | } | 523 | } | ||
590 | kgv->setBackgroundColor(KGraphViewerSettings::backgroundColor()); | 524 | kgv->setBackgroundColor(KGraphViewerSettings::backgroundColor()); | ||
591 | } | 525 | } | ||
592 | } | 526 | } |