This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Where to put my appnameui.rc?

Tags: None
(comma "," separated)
User avatar
Kusa
Registered Member
Posts
25
Karma
0
OS

Where to put my appnameui.rc?

Wed Aug 19, 2009 10:13 am
Hi all, on the road to kde devland (like hans xD), i try to introduce with KAction and i can't link my appnameui.rc :/ .
This is my CMakeLists.txt (everything is good):
Code: Select all
project (KXmlGuiWindow)
find_package( KDE4 REQUIRED)
include_directories(${KDE4_INCLUDES})
file( GLOB_RECURSE source_kxml src/* )
add_executable(KXmlWindow ${source_kxml} )
include(KDE4Defaults)
target_link_libraries(KXmlWindow ${KDE4_KDEUI_LIBS})
install(TARGETS KXmlWindow DESTINATION ${BIN_INSTALL_DIR})
install(FILES kxmlwindowui.rc DESTINATION ${DATA_INSTALL_DIR})


And this is my appnameui.rc(called kxmlwindowui.rc):
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<gui name="kxmlwindow"
     version="1"
     xmlns="http://www.kde.org/standards/kxmlgui/1.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0
                         http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd" >
 
  <MenuBar>
    <Menu name="file" >
      <Action name="clear" />
    </Menu>
  </MenuBar>
 
  <ToolBar name="mainToolBar" >
    <text>Main Toolbar</text>
    <Action name="clear" />
  </ToolBar>
 
</gui>


And finally my kxmlwindow.cpp and main.cpp ;):
Code: Select all
//kxmlwindow.cpp
#include "mainwin.h"
// The include for kde
#include <KApplication>
#include <KAction>
#include <KLocale>
#include <KActionCollection>
#include <KStandardAction>

MainWin::MainWin(QWidget *parent) : KXmlGuiWindow(parent)
{
    textArea = new KTextEdit;
    setCentralWidget(textArea);
    setupActions();
}

void MainWin::setupActions()
{
    KAction* clearAction = new KAction(this);
    clearAction->setText(i18n("Clear"));
    clearAction->setIcon(KIcon("document-new"));
    clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
    actionCollection()->addAction("clear", clearAction);
    connect(clearAction, SIGNAL(triggered(bool)),
          textArea, SLOT(clear()));
 
    KStandardAction::quit(kapp, SLOT(quit()),
                        actionCollection());
 
    setupGUI();
}


Code: Select all
#include <KApplication>
#include <KAboutData>
#include <KCmdLineArgs>

#include "mainwin.h"
#include <KLocale>

int main (int argc, char *argv[])
{

    KAboutData aboutData( "kxmlwindow", 0,ki18n("KAction"), "1.0",ki18n("On the road to kde devland"),KAboutData::License_GPL,ki18n("Copyright (c) 2009 Developer") );
    KCmdLineArgs::init(argc, argv, &aboutData);
    KApplication app;
    MainWin* window = new MainWin();
    window->show();
    return app.exec();
}


I have this message when i launch my app:
Code: Select all
[kusa@localhost KXmlWindow]$ ./KXmlWindow
kxmlwindow(5909)/kdeui (kdelibs): No such XML file "kxmlwindowui.rc"


Thanks a lot for your help.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Where to put my appnameui.rc?

Wed Aug 19, 2009 10:44 am
You need to change the following line in your CMakeLists.txt file to be as follows:
Code: Select all
install(FILES kxmlwindowui.rc DESTINATION ${DATA_INSTALL_DIR}/<NAME OF YOUR APPLICATION>)


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
Kusa
Registered Member
Posts
25
Karma
0
OS

Re: Where to put my appnameui.rc?

Wed Aug 19, 2009 11:14 am
Same problem with install(FILES kxmlwindowui.rc DESTINATION ${DATA_INSTALL_DIR}/KXmlWindow) :/

I have a folder called KXmlWindow, see ls command:
Code: Select all
[kusa@localhost KXmlWindow]$ ls
CMakeCache.txt       cmake_uninstall.cmake
CMakeFiles/          CTestTestfile.cmake
cmake_install.cmake  KXmlWindow*
CMakeLists.txt       kxmlwindowui.rc
CMakeLists.txt~      Makefile
CMakeTmp/            src/


In Src, i've main.cpp, mainwin.cpp, mainwin.h files... i don't understand KAction, QAction is more usably i think.


New french developper!!!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Where to put my appnameui.rc?

Wed Aug 19, 2009 11:32 am
Try installing it to: ${DATA_INSTALL_DIR}/kmxlguiwindow instead.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
Kusa
Registered Member
Posts
25
Karma
0
OS

Re: Where to put my appnameui.rc?

Wed Aug 19, 2009 11:56 am
Same Problem... my file .rc is in good place or not?


New french developper!!!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Where to put my appnameui.rc?

Wed Aug 19, 2009 12:21 pm
Can you please post the "mainwin.h" file so I can compile and test the source code?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
Kusa
Registered Member
Posts
25
Karma
0
OS

Re: Where to put my appnameui.rc?

Wed Aug 19, 2009 12:29 pm
Here comes :p

Code: Select all
#ifndef MAINWIN_H
#define MAINWIN_H

#include <KXmlGuiWindow>
#include <KTextEdit>

class MainWin : public KXmlGuiWindow
{
    public:
        MainWin(QWidget *parent = 0);
    private:
        KTextEdit* textArea;
        void setupActions();
};

#endif
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Where to put my appnameui.rc?

Wed Aug 19, 2009 1:16 pm
It worked for me.... I did make some small changes to the CMakeLists.txt file though.
Code: Select all
project( KXmlGuiWindow )
find_package( KDE4 REQUIRED )
include_directories( ${KDE4_INCLUDES} )
file( GLOB_RECURSE source_kxml src/* )
kde4_add_executable( kxmlwindow ${source_kxml} )
include( KDE4Defaults )
target_link_libraries( kxmlwindow ${KDE4_KDEUI_LIBS} )
install( TARGETS kxmlwindow DESTINATION ${BIN_INSTALL_DIR} )
install( FILES kxmlwindowui.rc DESTINATION ${DATA_INSTALL_DIR}/kxmlwindow )


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
Kusa
Registered Member
Posts
25
Karma
0
OS

Re: Where to put my appnameui.rc?

Wed Aug 19, 2009 1:28 pm
Hummm very strange, i try with your CMakeLists but it's the same problem, where did you place your kxmlwindowui.rc?


New french developper!!!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
When I ran CMake, I used the following command:
Code: Select all
cmake .. -DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix)


You then need to run "make install" ( may need sudo )


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
Kusa
Registered Member
Posts
25
Karma
0
OS

Re: Where to put my appnameui.rc?

Wed Aug 19, 2009 4:13 pm
Ok it's resolved but if i don't want to compile it with root??

Thank you a lot for your help ;D


New french developper!!!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Where to put my appnameui.rc?

Wed Aug 19, 2009 11:23 pm
You don't have to compile as root, but you will need to install as root.
Code: Select all
make
sudo make install


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
Jucato
Registered Member
Posts
67
Karma
1
OS

Re: Where to put my appnameui.rc?

Wed Aug 19, 2009 11:41 pm
You don't have to install as root if you're not going to install in a system directory like /usr (you can install, for example, in a special directory in you $HOME directory). But the point is that you have to install the app (with make install) to copy the .rc files to the correct directory.

Of course, running the app from a special KDE directory in your $HOME takes a few more extra steps. :)


Jucato, proud to be a member of KDE forums since 2008-Oct.


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]