Hi, I spent few days working on this and have created a configuration dialog in KoView with a virtual method which can be overridden by derived classes (for example, Table's part/View) to add their additional custom pages.
I have attached a patch that adds the common configuration dialog to libs/main/ and a sample in tables/part/view.cpp on how to add custom dialog pages. By compiling and running this, you should see two "Configure Tables" options in calligratables, the new one is the second one. Upon selecting that, you can see a dialog with the common "Open/Save" page from libs/main/dialogs/ and a custom page added from Tables. Please review the patch and let me know if I missed something anywhere, and when everyone is fine with it, I hope it can be merged. If the correct place for this is reviewboard, let me know and I'll put it there :) Thanks! -- Shantanu Tushar (UTC +0530) http://www.shantanutushar.com On Thu, Jan 13, 2011 at 7:23 PM, Shantanu Tushar Jha <jhahon...@gmail.com>wrote: > Hi all, > > We had a discussion on IRC about this (mainly with Boemann and Cyrille) > and we reached an agreement that the shared configuration dialogs can be > implemented using the same way tables does it using > tables/part/dialogs/PreferenceDialog. > > So the idea is to have a PreferenceDialog in libs/main/ which is then > loaded by a menu entry (corresponding to an action) in KoView. This in > effect should add the entry to all apps using KoView and hence we can share > common settings like autosave. > > An application can add custom pages to this dialog by calling a KoView > method with the Page it wishes to add. > > So, I will be implementing as said above, and being a newcomer here, I'd > really love to hear suggestions about this. Please reply! > > Cheers! > > > -- > > Shantanu Tushar (UTC +0530) > http://www.shantanutushar.com > > On Thu, Jan 13, 2011 at 1:32 PM, Cyrille Berger Skott <cber...@cberger.net > > wrote: > >> Hi, >> >> On Thursday 13 January 2011, Shantanu Tushar Jha wrote: >> > 1. Is the idea of sharing configuration dialog and common configuration >> > pages sane? I don't have much idea about Calligra's (and hence >> KOffice's) >> > history so if this has been already discussed, please point to the ML >> > thread. >> >> We had prior discussion on the subject, see [1]. It is all I could >> remember. >> Which lead to some config dialog to be put in libs/main/config see [2]. >> While >> it allows the widgets to be the same, it still requires editing each >> individual application. >> >> To conclude, yes it is a sane idea and a very wanted project :) >> >> > 2. To implement a shared dialog, where is the best place to add the >> dialog? >> > Being new to the codebase, lots of classes come to my mind (like >> > KOApplication, KODocument etc) so I need a little bit of help here. >> >> I guess all depends how much time you are willing to invest in this. If >> you >> only have time for the autosave configuration, the quickest road is to add >> a >> widget to libs/main/config, and make all application use that. However, if >> you >> want to invest yourself more in the subject, and create a setting dialog >> that >> would allow "calligra-wide" configuration option as well as "application- >> specific". I have outlined a possible solution in [3], the use of KCModule >> [4] >> would allow to move the settings to plugins. >> >> However, while I think it is an ideal solution, an intermediary solution >> would >> be to have a KoSettingsDialog inheriting KPageDialog, with a set of >> predefined >> pages, that can be extended by application for their own settings. The >> location of that dialog should be in libs/main, and it should probably be >> called from KoView. And I guess application specific pages could be >> created by >> adding a KoView::createPreferencesPage returning a list of >> KPageWidgetItem*. >> >> [1] http://lists.kde.org/?l=koffice-devel&m=124932729205268&w=2 >> [2] http://gitweb.kde.org/calligra.git/tree/HEAD:/libs/main/config >> [3] http://lists.kde.org/?l=koffice-devel&m=124937404927580&w=2 >> [4] >> http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKCModule.html >> -- >> Cyrille Berger Skott >> _______________________________________________ >> calligra-devel mailing list >> calligra-devel@kde.org >> https://mail.kde.org/mailman/listinfo/calligra-devel >> > > > >
diff --git a/libs/main/CMakeLists.txt b/libs/main/CMakeLists.txt index 457de07..50e59e9 100644 --- a/libs/main/CMakeLists.txt +++ b/libs/main/CMakeLists.txt @@ -84,7 +84,11 @@ set(komain_LIB_SRCS KoAction.cpp KoExecutePolicy.cpp KoJobsListPolicy.cpp + + KoConfigurationDialogPage.cpp + dialogs/KoConfigurationDialog.cpp ) + if( Soprano_FOUND ) set(komain_LIB_SRCS ${komain_LIB_SRCS} rdf/KoDocumentRdf.cpp @@ -119,7 +123,10 @@ kde4_add_ui_files( komain_LIB_SRCS koDocumentInfoAuthorWidget.ui KoOpenPaneBase.ui KoDetailsPaneBase.ui + + dialogs/KoOpenSaveConfigurationWidget.ui ) + if( Soprano_FOUND ) kde4_add_ui_files( komain_LIB_SRCS rdf/KoDocumentRdfEditWidget.ui @@ -220,4 +227,3 @@ if( Soprano_FOUND ) rdf/KoSemanticStylesheetsEditor.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel) endif( Soprano_FOUND ) - diff --git a/libs/main/KoConfigurationDialogPage.cpp b/libs/main/KoConfigurationDialogPage.cpp new file mode 100644 index 0000000..8ad20f2 --- /dev/null +++ b/libs/main/KoConfigurationDialogPage.cpp @@ -0,0 +1,56 @@ +/* This file is part of the KDE project + Copyright (C) 2011 Shantanu Tushar <jhahon...@gmail.com> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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. +*/ + + +#include "KoConfigurationDialogPage.h" + +KoConfigurationDialogPage::KoConfigurationDialogPage (QWidget* widget) : m_widget(widget) +{ + +} + +KoConfigurationDialogPage::~KoConfigurationDialogPage() +{ + +} + +QString KoConfigurationDialogPage::title() const +{ + return m_title; +} + +void KoConfigurationDialogPage::setTitle (const QString& title) +{ + m_title = title; +} + +KIcon KoConfigurationDialogPage::icon() const +{ + return m_icon; +} + +void KoConfigurationDialogPage::setIcon (const KIcon& icon) +{ + m_icon = icon; +} + +QWidget* KoConfigurationDialogPage::widget() +{ + return m_widget; +} diff --git a/libs/main/KoConfigurationDialogPage.h b/libs/main/KoConfigurationDialogPage.h new file mode 100644 index 0000000..ca843c9 --- /dev/null +++ b/libs/main/KoConfigurationDialogPage.h @@ -0,0 +1,51 @@ +/* This file is part of the KDE project + Copyright (C) 2011 Shantanu Tushar <jhahon...@gmail.com> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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. +*/ + + +#ifndef KOCONFIGURATIONDIALOGPAGE_H +#define KOCONFIGURATIONDIALOGPAGE_H + +#include "komain_export.h" + +#include <KIcon> + +class QWidget; + +class KOMAIN_EXPORT KoConfigurationDialogPage +{ + + public: + KoConfigurationDialogPage(QWidget *widget); + virtual ~KoConfigurationDialogPage(); + + QString title() const; + void setTitle(const QString &title); + + KIcon icon() const; + void setIcon(const KIcon &icon); + + QWidget *widget(); + + private: + QWidget *m_widget; + QString m_title; + KIcon m_icon; +}; + +#endif // KOCONFIGURATIONDIALOGPAGE_H diff --git a/libs/main/KoView.cpp b/libs/main/KoView.cpp index b09603d..386eb69 100644 --- a/libs/main/KoView.cpp +++ b/libs/main/KoView.cpp @@ -29,6 +29,8 @@ #include "KoMainWindow.h" #include "KoViewAdaptor.h" #include "KoDockFactoryBase.h" +#include "dialogs/KoConfigurationDialog.h" +#include "KoConfigurationDialogPage.h" #include <kactioncollection.h> #include <kglobalsettings.h> @@ -443,6 +445,9 @@ void KoView::setupGlobalActions() KAction *actionNewView = new KAction(KIcon("window-new"), i18n("&New View"), this); actionCollection()->addAction("view_newview", actionNewView); connect(actionNewView, SIGNAL(triggered(bool)), this, SLOT(newView())); + + actionCollection()->addAction(KStandardAction::Preferences, + "configure", this, SLOT(showConfigurationDialog())); } void KoView::newView() @@ -514,5 +519,18 @@ QList<QAction*> KoView::createChangeUnitActions() return answer; } +void KoView::showConfigurationDialog() +{ + KoConfigurationDialog dialog(this); + addCustomConfigurationDialogPages(&dialog); + dialog.exec(); +} + +void KoView::addCustomConfigurationDialogPages (KoConfigurationDialog* dialog) +{ + Q_UNUSED(dialog); +} + + #include <KoView_p.moc> #include <KoView.moc> diff --git a/libs/main/KoView.h b/libs/main/KoView.h index 7dfb232..9f8ccbc 100644 --- a/libs/main/KoView.h +++ b/libs/main/KoView.h @@ -30,6 +30,8 @@ class KoMainWindow; class KoPrintJob; class KoViewPrivate; class KoZoomController; +class KoConfigurationDialogPage; +class KoConfigurationDialog; // KDE classes class KStatusBar; @@ -302,7 +304,10 @@ protected: * Handles the event KParts::GUIActivateEvent. */ virtual void guiActivateEvent(KParts::GUIActivateEvent *); - + /** + * Subclasses can override this to add their custom configuration pages + */ + virtual void addCustomConfigurationDialogPages(KoConfigurationDialog *dialog); /** Generate a name for this view. @@ -336,6 +341,7 @@ signals: protected slots: virtual void slotAutoScroll(); + void showConfigurationDialog(); private: virtual void setupGlobalActions(void); diff --git a/libs/main/dialogs/KoConfigurationDialog.cpp b/libs/main/dialogs/KoConfigurationDialog.cpp new file mode 100644 index 0000000..e89e1c6 --- /dev/null +++ b/libs/main/dialogs/KoConfigurationDialog.cpp @@ -0,0 +1,48 @@ +/* This file is part of the KDE project + Copyright (C) 2011 Shantanu Tushar <jhahon...@gmail.com> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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. +*/ + + +#include "KoConfigurationDialog.h" +#include "../KoView.h" +#include "ui_KoOpenSaveConfigurationWidget.h" +#include "../KoConfigurationDialogPage.h" + +KoConfigurationDialog::KoConfigurationDialog (KoView* view) : KPageDialog (view) +{ + setFaceType(List); + + //Open/Save configuration page + QWidget *widget = new QWidget(this); + Ui::KoOpenSaveConfigurationWidget openSaveConfigurationWidget; + openSaveConfigurationWidget.setupUi(widget); + KPageWidgetItem *item = addPage(widget, i18n("Open/Save Configuration")); + item->setIcon(KIcon("document-save")); +} + +KoConfigurationDialog::~KoConfigurationDialog() +{ +} + +void KoConfigurationDialog::addCustomPage (KoConfigurationDialogPage* page) +{ + KPageWidgetItem *item = addPage(page->widget(), page->title()); + item->setIcon(page->icon()); +} + +#include "KoConfigurationDialog.moc" diff --git a/libs/main/dialogs/KoConfigurationDialog.h b/libs/main/dialogs/KoConfigurationDialog.h new file mode 100644 index 0000000..ffd20e4 --- /dev/null +++ b/libs/main/dialogs/KoConfigurationDialog.h @@ -0,0 +1,42 @@ +/* This file is part of the KDE project + Copyright (C) 2011 Shantanu Tushar <jhahon...@gmail.com> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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. +*/ + + +#ifndef KOCONFIGURATIONDIALOG_H +#define KOCONFIGURATIONDIALOG_H + +#include <KPageDialog> +#include <QList> + +#include "komain_export.h" + +class KoView; +class KoConfigurationDialogPage; + +class KOMAIN_EXPORT KoConfigurationDialog : public KPageDialog +{ + Q_OBJECT + + public: + explicit KoConfigurationDialog (KoView *view); + virtual ~KoConfigurationDialog(); + void addCustomPage(KoConfigurationDialogPage *page); +}; + +#endif // KOCONFIGURATIONDIALOG_H diff --git a/libs/main/dialogs/KoOpenSaveConfigurationWidget.ui b/libs/main/dialogs/KoOpenSaveConfigurationWidget.ui new file mode 100644 index 0000000..d3937b3 --- /dev/null +++ b/libs/main/dialogs/KoOpenSaveConfigurationWidget.ui @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>KoOpenSaveConfigurationWidget</class> + <widget class="QWidget" name="KoOpenSaveConfigurationWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>373</width> + <height>75</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Autosave delay (minutes):</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="KIntSpinBox" name="m_autoSaveDelay"> + <property name="whatsThis"> + <string>Here you can select the time between autosaves, or disable this feature altogether by choosing Do not save automatically (drag the slider to the far left).</string> + </property> + <property name="specialValueText"> + <string>Do not save automatically</string> + </property> + <property name="suffix"> + <string> min</string> + </property> + <property name="maximum"> + <number>60</number> + </property> + <property name="value"> + <number>10</number> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>37</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>KIntSpinBox</class> + <extends>QSpinBox</extends> + <header>knuminput.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/tables/part/View.cpp b/tables/part/View.cpp index 8b9ba78..9cc4717 100644 --- a/tables/part/View.cpp +++ b/tables/part/View.cpp @@ -10,7 +10,7 @@ Copyright 1999-2001 Simon Hausmann <hausm...@kde.org> Copyright 1998-2000 Torben Weis <w...@kde.org> Copyright 2010 Boudewijn Rempt <b...@kogmbh.com> - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -104,6 +104,7 @@ #include <KoZoomController.h> #include <KoZoomHandler.h> #include <KoToolProxy.h> +#include <KoConfigurationDialogPage.h> // KSpread includes #include "ApplicationSettings.h" @@ -162,6 +163,7 @@ // D-Bus #include "interfaces/ViewAdaptor.h" #include <QtDBus/QtDBus> +#include <dialogs/KoConfigurationDialog.h> using namespace Calligra::Tables; @@ -2133,4 +2135,19 @@ KoPrintJob * View::createPrintJob() return new PrintJob(this); } +void View::addCustomConfigurationDialogPages (KoConfigurationDialog* dialog) +{ + //Sample pages + //Add Tables configuration dialogs to standard configuration dialog + QWidget *widget = new QWidget; + SheetPropertiesWidget sheetPropertyWidget(this); + sheetPropertyWidget.setupUi(widget); + + KoConfigurationDialogPage *page = new KoConfigurationDialogPage(widget); + page->setTitle("Tables custom page"); + page->setIcon(KIcon("kde")); + + dialog->addCustomPage(page); +} + #include "View.moc" diff --git a/tables/part/View.h b/tables/part/View.h index a542637..f84a16b 100644 --- a/tables/part/View.h +++ b/tables/part/View.h @@ -352,6 +352,8 @@ protected: // reimplementations virtual void updateReadWrite(bool readwrite); virtual void guiActivateEvent(KParts::GUIActivateEvent *ev); virtual KoPrintJob * createPrintJob(); + virtual void addCustomConfigurationDialogPages (KoConfigurationDialog* dialog); + public: virtual KoZoomController *zoomController() const; diff --git a/tables/tables.rc b/tables/tables.rc index 0fde1b6..fbbadae 100644 --- a/tables/tables.rc +++ b/tables/tables.rc @@ -183,6 +183,7 @@ <Action name="showStatusBar" group="settings_show" /> <Action name="configureNotifications" group="settings_configure"/> <Action name="preference" group="settings_configure"/> + <Action name="configure" group="settings_configure"/> </Menu> </MenuBar>
_______________________________________________ calligra-devel mailing list calligra-devel@kde.org https://mail.kde.org/mailman/listinfo/calligra-devel