Commit 1c120cb0 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Make Krita a QtSingleApplication

CCMAIL:kimageshop@kde.org

If there is a running instance of Krita, and you open another image with Krita,
or start Krita from the commandline, the files in the arguments are opened in
the first Krita.

This also solves synchronization issues with the tag store, as well as possible
issues with setting shortcuts. (Though not all shortcut issues are solved yet).

BUG:342187 Possibility to open images in one krita app
BUG:318208 With multiple instance of Krita open, preset tags get out of sync
parent e28583c6
......@@ -141,20 +141,14 @@ if (NOT WIN32)
add_subdirectory( benchmarks )
endif (NOT WIN32)
set(kritapart_PART_SRCS krita_part_init.cc)
kde4_add_plugin(kritapart ${kritapart_PART_SRCS})
target_link_libraries(kritapart kritaui)
install(TARGETS kritapart DESTINATION ${PLUGIN_INSTALL_DIR})
set(krita_KDEINIT_SRCS main.cc)
set(krita_SRCS main.cc)
if(WIN32 AND USE_BREAKPAD)
set(krita_KDEINIT_SRCS ${krita_KDEINIT_SRCS} kis_crash_handler.cpp)
set(krita_SRCS ${krita_SRCS} kis_crash_handler.cpp)
set(BREAKPAD_LIBS breakpad)
endif(WIN32 AND USE_BREAKPAD)
kde4_add_app_icon(krita_KDEINIT_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/pics/app/hi*-app-calligrakrita.png")
kde4_add_kdeinit_executable(krita ${krita_KDEINIT_SRCS})
kde4_add_app_icon(krita_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/pics/app/hi*-app-calligrakrita.png")
if (Q_WS_MAC)
set_target_properties(krita PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.template)
......@@ -162,13 +156,11 @@ if (Q_WS_MAC)
set_target_properties(krita PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Krita")
endif (Q_WS_MAC)
target_link_libraries(kdeinit_krita kritaui ${BREAKPAD_LIBS})
target_link_libraries(krita kdeinit_krita kritaui)
kde4_add_executable(krita ${krita_SRCS})
target_link_libraries(krita kritaui ${BREAKPAD_LIBS})
install(TARGETS krita ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS kdeinit_krita ${INSTALL_TARGETS_DEFAULT_ARGS})
install(PROGRAMS krita.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}/calligra)
install(FILES kritapart.desktop DESTINATION ${SERVICES_INSTALL_DIR}/calligra)
install(FILES krita.rc DESTINATION ${DATA_INSTALL_DIR}/krita)
install(FILES krita.appdata.xml DESTINATION ${SHARE_INSTALL_PREFIX}/appdata/ )
......
......@@ -131,9 +131,9 @@ Type=Application
Icon=calligrakrita
Categories=Qt;KDE;Graphics;
X-KDE-ServiceTypes=Calligra/Application
X-Calligra-DefaultMimeTypes=application/x-krita;application/x-krita-animation
X-Calligra-DefaultMimeTypes=application/x-krita
X-KDE-NativeMimeType=application/x-krita
X-KDE-ExtraNativeMimeTypes=application/x-krita-animation
X-KDE-ExtraNativeMimeTypes=
StartupNotify=true
X-DBUS-StartupType=Multi
X-DBUS-ServiceName=org.krita.krita
......
[Desktop Entry]
Name=Calligra Painting and Image Editor Component
Name[bg]=Компонент за рисуване и редактиране на изображения в Calligra
Name[bs]=Clligra Komponenta za Bojenje i Editovanje Slika
Name[ca]=Component de dibuix i manipulació d'imatges del Calligra
Name[ca@valencia]=Component de dibuix i manipulació d'imatges del Calligra
Name[cs]=Komponenta Calligra pro malování a úpravu fotografií
Name[da]=Calligra-komponent til tegning og billedredigeringskomponent
Name[de]=Calligra-Komponente für Malen und Bildbearbeitung
Name[el]=Συστατικό επεξεργασίας και ζωγραφικής εικόνων του Calligra
Name[en_GB]=Calligra Painting and Image Editor Component
Name[es]=Componente de pintura y de edición de imágenes de Calligra
Name[et]=Calligra joonistamise ja pilditöötluse komponent
Name[eu]=Calligra-ren pinturaren eta irudi-editorearen osagaia
Name[fi]=Calligran maalaus- ja kuvankäsittelyosa
Name[fr]=Composant manipulation d'images et dessin de Calligra
Name[gl]=Compoñente para Calligra de debuxo e edición de imaxes
Name[hu]=Calligra rajzoló és képszerkesztő komponens
Name[it]=Componente per il disegno e la manipolazione di immagini di Calligra
Name[ja]=Calligra 描画と画像編集コンポーネント
Name[kk]=Calligra-ның кескінін салу және өңдеу бағдарламасы
Name[ko]=Calligra 그리기 및 그림 편집기 구성 요소
Name[nb]=Calligra-komponent for maling og bildemanipulasjon
Name[nds]=Calligra-Komponent för't Malen un Bildbewerken
Name[nl]=Calligra-component voor tekenen en afbeeldingsbewerking
Name[pl]=Składnik malowania i edycji obrazu dla Calligry
Name[pt]=Componente de Edição e Pintura de Imagens do Calligra
Name[pt_BR]=Componente de Edição e Pintura de Imagens do Calligra
Name[ru]=Компонент рисования и редактирования изображений Calligra
Name[sk]=Calligra modul na úpravu a maľovanie obrázkov
Name[sl]=Komponenta za slikanje in urejanje slik za Calligro
Name[sv]=Calligra målnings- och bildredigeringskomponent
Name[uk]=Компонент Calligra для малювання і редагування зображень
Name[x-test]=xxCalligra Painting and Image Editor Componentxx
Name[zh_CN]=Calligra 绘图和图像编辑器组件
Name[zh_TW]=Calligra 繪圖與影像編輯元件
X-KDE-Library=kritapart
MimeType=application/x-krita;image/openraster;
Type=Service
X-KDE-ServiceTypes=Calligra/Part
X-KDE-NativeMimeType=application/x-krita
GenericName=Image Object
GenericName[bg]=Графично изображение
GenericName[br]=Tra skeudenn
GenericName[bs]=Objekat slike
GenericName[ca]=Objecte d'imatge
GenericName[ca@valencia]=Objecte d'imatge
GenericName[cy]=Gwrthrych Delwedd
GenericName[da]=Billedobjekt
GenericName[de]=Bildobjekt
GenericName[el]=Αντικείμενο εικόνας
GenericName[en_GB]=Image Object
GenericName[eo]=Bildobjekto
GenericName[es]=Objeto de imagen
GenericName[et]=Pildiobjekt
GenericName[eu]=Irudi-objektua
GenericName[fa]=شیء تصویر
GenericName[fi]=Kuvaobjekti
GenericName[fr]=Objet image
GenericName[fy]=Ofbylding
GenericName[ga]=Réad Íomhá
GenericName[gl]=Obxecto de imaxe
GenericName[he]=אובייקט תמונה
GenericName[hi]=छवि ऑब्जेक्ट
GenericName[hne]=फोटू आब्जेक्ट
GenericName[hr]=Objekt slike
GenericName[hu]=Képobjektum
GenericName[is]=Myndhluti
GenericName[it]=Oggetto immagine
GenericName[ja]=画像オブジェクト
GenericName[kk]=Кескін
GenericName[ko]=그림 객체
GenericName[lv]=Attēla objekts
GenericName[nb]=Bildeobjekt
GenericName[nds]=Bildobjekt
GenericName[ne]=छवि वस्तु
GenericName[nl]=Afbeelding
GenericName[pl]=Obiekt obrazu
GenericName[pt]=Objecto de Imagem
GenericName[pt_BR]=Objeto de Imagem
GenericName[ru]=Рисунок
GenericName[sk]=Objekt obrázok
GenericName[sl]=Slika
GenericName[sv]=Bildobjekt
GenericName[tr]=Resim Nesnesi
GenericName[uk]=Об’єкт зображення
GenericName[uz]=Rasm obʼekti
GenericName[uz@cyrillic]=Расм объекти
GenericName[wa]=Cayet imådje
GenericName[x-test]=xxImage Objectxx
GenericName[zh_CN]=图像对象
GenericName[zh_TW]=圖片物件
Icon=calligrakrita
X-Krita-Version=28
......@@ -54,7 +54,7 @@
#endif
extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
extern "C" int main(int argc, char **argv)
{
bool runningInKDE = !qgetenv("KDE_FULL_SESSION").isEmpty();
......@@ -63,6 +63,7 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
qputenv("QT_NO_GLIB", "1");
}
#endif
#ifdef USE_BREAKPAD
qputenv("KDE_DEBUG", "1");
KisCrashHandler crashHandler;
......@@ -74,6 +75,8 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
#endif
int state;
KisFactory factory;
Q_UNUSED(factory); // Not really, it'll self-destruct on exiting main
KAboutData *aboutData = KisFactory::aboutData();
KCmdLineArgs::init(argc, argv, aboutData);
......@@ -90,8 +93,29 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
KCmdLineArgs::addCmdLineOptions(options);
// A per-user unique string, without /, because QLocalServer cannot use names with a / in it
QString key = "Krita" +
QDesktopServices::storageLocation(QDesktopServices::HomeLocation).replace("/", "_");
key = key.replace(":", "_").replace("\\","_");
// initialize qt plugin path (see KComponentDataPrivate::lazyInit)
KGlobal::config();
// first create the application so we can create a pixmap
KisApplication app;
KisApplication app(key);
if (app.isRunning()) {
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
QByteArray ba;
QDataStream ds(&ba, QIODevice::WriteOnly);
args->saveAppArgs(ds);
ds.device()->close();
if (app.sendMessage(ba)) {
return 0;
}
}
#if defined Q_OS_WIN
KisTabletSupportWin::init();
......@@ -105,9 +129,8 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
app.setAttribute(Qt::AA_X11InitThreads, true);
#endif
if (!runningInKDE) {
app.setAttribute(Qt::AA_DontShowIconsInMenus);
}
// Icons in menus are ugly and distracting
app.setAttribute(Qt::AA_DontShowIconsInMenus);
// then create the pixmap from an xpm: we cannot get the
// location of our datadir before we've started our components,
......@@ -119,6 +142,14 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
return 1;
}
// Set up remote arguments.
QObject::connect(&app, SIGNAL(messageReceived(QByteArray,QObject*)),
&app, SLOT(remoteArguments(QByteArray,QObject*)));
QObject::connect(&app, SIGNAL(fileOpenRequest(QString)),
&app, SLOT(fileOpenRequested(QString)));
state = app.exec();
return state;
......
......@@ -23,7 +23,7 @@
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kcomponentdata.h>
#include <kglobal.h>
#include <kaction.h>
#include <kactioncollection.h>
......
......@@ -44,7 +44,6 @@
#include <kis_debug.h>
#include <kmenu.h>
#include <klocale.h>
#include <kactioncollection.h>
#include <KoIcon.h>
#include <KisDocumentSectionView.h>
......@@ -81,7 +80,9 @@
class ButtonAction : public KisAction
{
public:
ButtonAction(QAbstractButton* button, const KIcon& icon, const QString& text, QObject* parent) : KisAction(icon, text, parent) , m_button(button)
ButtonAction(QAbstractButton* button, const KIcon& icon, const QString& text, QObject* parent)
: KisAction(icon, text, parent)
, m_button(button)
{
connect(m_button, SIGNAL(clicked()), this, SLOT(trigger()));
}
......@@ -231,7 +232,7 @@ KisLayerBox::KisLayerBox()
m_selectOpaque = new KisAction(i18n("&Select Opaque"), this);
m_selectOpaque->setActivationFlags(KisAction::ACTIVE_LAYER);
m_selectOpaque->setObjectName(""); // no name to avoid addition to the action collection
m_selectOpaque->setObjectName("select_opaque");
connect(m_selectOpaque, SIGNAL(triggered(bool)), this, SLOT(slotSelectOpaque()));
m_actions.append(m_selectOpaque);
......
......@@ -16,6 +16,8 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/widgets/resources
${CMAKE_CURRENT_SOURCE_DIR}/ora
${CMAKE_SOURCE_DIR}/krita/image/metadata
${CMAKE_SOURCE_DIR}/krita/ui/qtsingleapplication
${CMAKE_SOURCE_DIR}/krita/ui/qtlockedfile
${EXIV2_INCLUDE_DIR}
${OCIO_INCLUDE_DIR})
......@@ -317,6 +319,12 @@ set(kritaui_LIB_SRCS
kis_mainwindow_observer.cpp
KisViewManager.cpp
kis_mirror_manager.cpp
qtlockedfile/qtlockedfile.cpp
qtsingleapplication/qtlocalpeer.cpp
qtsingleapplication/qtsingleapplication.cpp
)
if(WIN32)
......@@ -324,6 +332,7 @@ if(WIN32)
${kritaui_LIB_SRCS}
input/kis_tablet_event.cpp
input/wintab/kis_tablet_support_win.cpp
qtlockedfile/qtlockedfile_win.cpp
)
endif(WIN32)
......@@ -332,6 +341,7 @@ if(UNIX)
${kritaui_LIB_SRCS}
input/kis_tablet_event.cpp
input/wintab/kis_tablet_support.cpp
qtlockedfile/qtlockedfile_unix.cpp
)
if(NOT APPLE)
set(kritaui_LIB_SRCS
......
......@@ -31,6 +31,7 @@
#include <KoDpi.h>
#include "KoGlobal.h"
#include <kcrash.h>
#include <kdeversion.h>
#include <klocale.h>
#include <kcmdlineargs.h>
......@@ -136,8 +137,8 @@ public:
KisApplication::KisApplication()
: KApplication()
KisApplication::KisApplication(const QString &key)
: QtSingleApplication(key, KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv())
, d(new KisApplicationPrivate)
{
KisApplication::KoApp = this;
......@@ -148,6 +149,18 @@ KisApplication::KisApplication()
// Initialize all Calligra directories etc.
KoGlobal::initialize();
setApplicationName(KGlobal::mainComponent().componentName());
setOrganizationDomain(KGlobal::mainComponent().aboutData()->organizationDomain());
setApplicationVersion(KGlobal::mainComponent().aboutData()->version());
// make sure the clipboard is created before setting the window icon (bug 209263)
(void) QApplication::clipboard();
setWindowIcon(KIcon(KGlobal::mainComponent().aboutData()->programIconName()));
KCrash::setDrKonqiEnabled(true);
KCrash::setApplicationName(applicationName());
KCrash::setApplicationPath(QCoreApplication::applicationDirPath());
#ifdef Q_OS_MACX
if ( QSysInfo::MacintoshVersion > QSysInfo::MV_10_8 )
{
......@@ -158,6 +171,7 @@ KisApplication::KisApplication()
setAttribute(Qt::AA_DontShowIconsInMenus, true);
#endif
if (applicationName() == "krita" && qgetenv("KDE_FULL_SESSION").isEmpty()) {
// There are two themes that work for Krita, oxygen and plastique. Try to set plastique first, then oxygen
setStyle("Plastique");
......@@ -180,7 +194,7 @@ BOOL isWow64()
//and GetProcAddress to get a pointer to the function if available.
fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
if(NULL != fnIsWow64Process)
{
......@@ -283,18 +297,8 @@ bool KisApplication::start()
&& !exportAs
&& !profileFileName.isEmpty());
// Figure out _which_ application we actually are
KisDocumentEntry entry = KisDocumentEntry::queryByMimeType(KIS_MIME_TYPE);
if (entry.isEmpty()) {
QMessageBox::critical(0, i18nc("@title:window", "Krita: Critical Error"), i18n("Essential application components could not be found.\n"
"This might be an installation issue.\n"
"Try restarting or reinstalling."));
return false;
}
// Load various global plugins
KoShapeRegistry* r = KoShapeRegistry::instance();
r->add(new KisShapeSelectionFactory());
......@@ -484,11 +488,9 @@ void KisApplication::setSplashScreen(QWidget *splashScreen)
QStringList KisApplication::mimeFilter(KisImportExportManager::Direction direction) const
{
KisDocumentEntry entry = KisDocumentEntry::queryByMimeType(KIS_MIME_TYPE);
KService::Ptr service = entry.service();
return KisImportExportManager::mimeFilter(KIS_MIME_TYPE,
direction,
service->property("X-KDE-ExtraNativeMimeTypes", QVariant::StringList).toStringList());
direction,
KisDocumentEntry::extraNativeMimeTypes());
}
......@@ -512,10 +514,57 @@ KisApplication *KisApplication::koApplication()
return KoApp;
}
void KisApplication::remoteArguments(const QByteArray &message, QObject *socket)
{
Q_UNUSED(socket);
int KisApplication::checkAutosaveFiles(KisMainWindow *mainWindow)
QDataStream ds(message);
KCmdLineArgs::loadAppArgs(ds);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
int argsCount = args->count();
KisMainWindow *mw = qobject_cast<KisMainWindow*>(qApp->activeWindow());
if (!mw) {
mw = KisPart::instance()->mainWindows().first();
}
if (!mw) {
return;
}
if (argsCount > 0) {
// Loop through arguments
for (int argNumber = 0; argNumber < argsCount; argNumber++) {
KUrl url = args->url(argNumber);
if (url.isValid()) {
KisDocument *doc = KisPart::instance()->createDocument();
if (doc) {
mw->openDocumentInternal(url, doc);
}
}
}
}
}
void KisApplication::fileOpenRequested(const QString &url)
{
KisDocument *doc = KisPart::instance()->createDocument();
KisPart::instance()->addDocument(doc);
KisMainWindow *mainWindow = KisPart::instance()->mainWindows().first();
if (mainWindow) {
mainWindow->openDocumentInternal(url, doc);
}
}
int KisApplication::checkAutosaveFiles(KisMainWindow *mainWindow)
{
// Check for autosave files from a previous run. There can be several, and
// we want to offer a restore for every one. Including a nice thumbnail!
QStringList autoSaveFiles;
......@@ -535,9 +584,9 @@ int KisApplication::checkAutosaveFiles(KisMainWindow *mainWindow)
filters << QString(".%1-%2-%3-autosave%4").arg("krita").arg("*").arg("*").arg(extension);
#ifdef Q_OS_WIN
QDir dir = QDir::tempPath();
QDir dir = QDir::tempPath();
#else
QDir dir = QDir::home();
QDir dir = QDir::home();
#endif
// all autosave files for our application
......@@ -545,7 +594,7 @@ int KisApplication::checkAutosaveFiles(KisMainWindow *mainWindow)
QStringList pids;
QString ourPid;
ourPid.setNum(kapp->applicationPid());
ourPid.setNum(qApp->applicationPid());
#ifndef QT_NO_DBUS
// all running instances of our application -- bit hackish, but we cannot get at the dbus name here, for some reason
......@@ -610,7 +659,7 @@ int KisApplication::checkAutosaveFiles(KisMainWindow *mainWindow)
mainWindow->openDocumentInternal(url, doc);
}
if (doc) {
if (doc) {
doc->resetURL();
doc->setModified(true);
QFile::remove(url.toLocalFile());
......
......@@ -20,7 +20,7 @@
#ifndef KIS_APPLICATION_H
#define KIS_APPLICATION_H
#include <kapplication.h>
#include <qtsingleapplication/qtsingleapplication.h>
#include "krita_export.h"
class KisPart;
......@@ -46,7 +46,7 @@ class QStringList;
* If the last mainwindow becomes closed, KisApplication automatically
* calls QApplication::quit.
*/
class KRITAUI_EXPORT KisApplication : public KApplication
class KRITAUI_EXPORT KisApplication : public QtSingleApplication
{
Q_OBJECT
......@@ -55,7 +55,7 @@ public:
* Creates an application object, adds some standard directories and
* initializes kimgio.
*/
explicit KisApplication();
explicit KisApplication(const QString &key);
/**
* Destructor.
......@@ -82,11 +82,6 @@ public:
*/
void setSplashScreen(QWidget *splash);
/**
* Remove the splash dialog
*/
void removeSplash();
/**
* return a list of mimetypes this application supports.
*/
......@@ -112,6 +107,11 @@ protected:
// Current application object.
static KisApplication *KoApp;
public slots:
void remoteArguments(const QByteArray &message, QObject*socket);
void fileOpenRequested(const QString & url);
private:
/// @return the number of autosavefiles opened
int checkAutosaveFiles(KisMainWindow *mainWindow);
......
......@@ -44,6 +44,16 @@ KisDocumentEntry::~KisDocumentEntry()
{
}
QString KisDocumentEntry::nativeMimeType()
{
return QString::fromLatin1(KIS_MIME_TYPE);
}
QStringList KisDocumentEntry::extraNativeMimeTypes()
{
return QStringList() << KIS_MIME_TYPE;
}
KService::Ptr KisDocumentEntry::service() const {
return m_service;
......
......@@ -49,6 +49,10 @@ public:
explicit KisDocumentEntry(const KService::Ptr& service);
~KisDocumentEntry();
static QString nativeMimeType();
static QStringList extraNativeMimeTypes();
KService::Ptr service() const;
/**
......
......@@ -521,12 +521,7 @@ KisDocument* KisFilterChain::createDocument(const QString& file)
KisDocument* KisFilterChain::createDocument(const QByteArray& mimeType)
{
KisDocumentEntry entry = KisDocumentEntry::queryByMimeType(mimeType);
if (entry.isEmpty()) {
kError(30500) << "Couldn't find a part that can handle mimetype " << mimeType << endl;
}
Q_UNUSED(mimeType);
return KisPart::instance()->createDocument();
}
......
......@@ -307,7 +307,7 @@ KisMainWindow::KisMainWindow()
d->toolOptionsDocker = qobject_cast<KoToolDocker*>(createDockWidget(&toolDockerFactory));
KoToolBoxFactory toolBoxFactory;
QDockWidget* toolbox = createDockWidget(&toolBoxFactory);
createDockWidget(&toolBoxFactory);
foreach(const QString & docker, KoDockRegistry::instance()->keys()) {
KoDockFactoryBase *factory = KoDockRegistry::instance()->value(docker);
......@@ -377,9 +377,8 @@ KisMainWindow::KisMainWindow()
QString doc;
QStringList allFiles = KGlobal::dirs()->findAllResources("data", "krita/krita.rc");
setXMLFile(findMostRecentXMLFile(allFiles, doc));
setLocalXMLFile(KStandardDirs::locateLocal("data", "krita/krita.rc"));
guiFactory()->addClient( this );
guiFactory()->addClient(this);
// Create and plug toolbar list for Settings menu
QList<QAction *> toolbarList;
......@@ -1709,8 +1708,7 @@ QDockWidget* KisMainWindow::createDockWidget(KoDockFactoryBase* factory)
KConfigGroup group(KGlobal::config(), "GUI");
QFont dockWidgetFont = KGlobalSettings::generalFont();
qreal pointSize = group.readEntry("palettefontsize", dockWidgetFont.pointSize() * 0.75);
pointSize = qMax(pointSize, KGlobalSettings::smallestReadableFont().pointSizeF());
dockWidgetFont.setPointSizeF(pointSize);
dockWidgetFont.setPointSizeF(qMax(pointSize, KGlobalSettings::smallestReadableFont().pointSizeF()));
#ifdef Q_OS_MAC
dockWidget->setAttribute(Qt::WA_MacSmallSize, true);
#endif
......@@ -1723,13 +1721,13 @@ QDockWidget* KisMainWindow::createDockWidget(KoDockFactoryBase* factory)
void KisMainWindow::forceDockTabFonts()
{
QObjectList chis = children();
for (int i = 0; i < chis.size(); ++i) {
if (chis.at(i)->inherits("QTabBar")) {
foreach(QObject *child, children()) {
if (child->inherits("QTabBar")) {
KConfigGroup group(KGlobal::config(), "GUI");
QFont dockWidgetFont = KGlobalSettings::generalFont();
qreal pointSize = KGlobalSettings::smallestReadableFont().pointSizeF();
dockWidgetFont.setPointSizeF(pointSize);
((QTabBar *)chis.at(i))->setFont(dockWidgetFont);
qreal pointSize = group.readEntry("palettefontsize", dockWidgetFont.pointSize() * 0.75);
dockWidgetFont.setPointSizeF(qMax(pointSize, KGlobalSettings::smallestReadableFont().pointSizeF()));
((QTabBar *)child)->setFont(dockWidgetFont);
}
}
}
......@@ -1748,6 +1746,9 @@ QList<KoCanvasObserverBase*> KisMainWindow::canvasObservers()
if (observer) {
observers << observer;
}
else {
qWarning() << docker << "is not a canvas observer";
}
}
return observers;
}
......@@ -1808,6 +1809,7 @@ void KisMainWindow::subWindowActivated()
}
updateCaption();
d->viewManager->actionManager()->updateGUI();
}
void KisMainWindow::updateWindowMenu()
......@@ -1885,6 +1887,7 @@ void KisMainWindow::setActiveSubWindow(QWidget *window)
d->activeSubWindow = subwin;
}
updateWindowMenu();
d->viewManager->actionManager()->updateGUI();
}
void KisMainWindow::configChanged()
......@@ -1899,6 +1902,7 @@ void KisMainWindow::configChanged()
KConfigGroup group(KGlobal::config(), "theme");
d->themeManager->setCurrentTheme(group.readEntry("Theme", "Krita dark"));
d->viewManager->actionManager()->updateGUI();
}
void KisMainWindow::newView(QObject *document)
......@@ -1906,18 +1910,18 @@ void KisMainWindow::newView(QObject *document)
KisDocument *doc = qobject_cast<KisDocument*>(document);
KisView *view = KisPart::instance()->createView(doc, this);
addView(view);
qDebug() << "?>>>>>>>>>>>>>>>>" << KActionCollection::allCollections().size();
d->viewManager->actionManager()->updateGUI();
}
void KisMainWindow::newWindow()
{
qDebug() << "?>>>>>>>>>>>>>>>>" << KActionCollection::allCollections().size();
KisPart::instance()->createMainWindow()->show();
}
void KisMainWindow::closeCurrentWindow()
{
d->mdiArea->currentSubWindow()->close();
d->viewManager->actionManager()->updateGUI();
}
void KisMainWindow::showAboutApplication()
......
......@@ -124,13 +124,6 @@ public:
void setReadWrite(bool readwrite);
/**
* Returns the dockwidget specified by the @p factory. If the dock widget doesn't exist yet it's created.
* Add a "view_palette_action_menu" action to your view menu if you want to use closable dock widgets.
* @param factory the factory used to create the dock widget if needed
* @return the dock widget specified by @p factory (may be 0)
*/
QDockWidget* createDockWidget(KoDockFactoryBase* factory);
/// Return the list of dock widgets belonging to this main window.
QList<QDockWidget*> dockWidgets();
......@@ -373,14 +366,14 @@ private:
friend class KisApplication;
/**
* This setting indicates who is calling chooseNewDocument.
* Usually the app will want to
* - show the template dialog with 'everything' if InitDocAppStarting, InitDocFileClose or InitDocEmbedded
* - show the template dialog with 'templates only' if InitDocFileNew
* - create an empty document with default settings if InitDocEmpty
* Returns the dockwidget specified by the @p factory. If the dock widget doesn't exist yet it's created.
* Add a "view_palette_action_menu" action to your view menu if you want to use closable dock widgets.
* @param factory the factory used to create the dock widget if needed
* @return the dock widget specified by @p factory (may be 0)
*/
enum InitDocFlags { /*InitDocAppStarting, */ InitDocFileNew, InitDocFileClose /*, InitDocEmbedded, InitDocEmpty*/ };
QDockWidget* createDockWidget(KoDockFactoryBase* factory);
/**
* Ask user about saving changes to the document upon exit.
......
......@@ -19,6 +19,8 @@
#include "kis_action_manager.h"
#include <QList>
#include <kstandarddirs.h>
#include <kactioncollection.h>
#include "KisPart.h"
......@@ -31,6 +33,8 @@
#include "kis_layer.h"
#include "KisDocument.h"
class KisActionManager::Private {
public:
......@@ -42,12 +46,17 @@ public:
QList<KisAction*> actions;
KoGenericRegistry<KisOperationUIFactory*> uiRegistry;
KisOperationRegistry operationRegistry;
};
KisActionManager::KisActionManager(KisViewManager* viewManager)
: d(new Private)
{
d->viewManager = viewManager;
QString kritarc = KStandardDirs::locate("data", "krita/krita.rc");