mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-27 04:13:05 +00:00
94 lines
2.6 KiB
C++
94 lines
2.6 KiB
C++
/*
|
|
* kde4app.cpp
|
|
*
|
|
* Copyright (C) 2008 %{AUTHOR} <%{EMAIL}>
|
|
*/
|
|
#include "kde4app.h"
|
|
#include "kde4appview.h"
|
|
#include "settings.h"
|
|
|
|
#include <QtGui/QDropEvent>
|
|
#include <QtGui/QPainter>
|
|
#include <QtGui/QPrinter>
|
|
|
|
#include <kconfigdialog.h>
|
|
#include <kstatusbar.h>
|
|
|
|
#include <kaction.h>
|
|
#include <kactioncollection.h>
|
|
#include <kstandardaction.h>
|
|
|
|
#include <KDE/KLocale>
|
|
|
|
kde4app::kde4app()
|
|
: KXmlGuiWindow(),
|
|
m_view(new kde4appView(this)),
|
|
m_printer(0)
|
|
{
|
|
// accept dnd
|
|
setAcceptDrops(true);
|
|
|
|
// tell the KXmlGuiWindow that this is indeed the main widget
|
|
setCentralWidget(m_view);
|
|
|
|
// then, setup our actions
|
|
setupActions();
|
|
|
|
// add a status bar
|
|
statusBar()->show();
|
|
|
|
// a call to KXmlGuiWindow::setupGUI() populates the GUI
|
|
// with actions, using KXMLGUI.
|
|
// It also applies the saved mainwindow settings, if any, and ask the
|
|
// mainwindow to automatically save settings if changed: window size,
|
|
// toolbar position, icon size, etc.
|
|
setupGUI();
|
|
}
|
|
|
|
kde4app::~kde4app()
|
|
{
|
|
}
|
|
|
|
void kde4app::setupActions()
|
|
{
|
|
KStandardAction::openNew(this, SLOT(fileNew()), actionCollection());
|
|
KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollection());
|
|
|
|
KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
|
|
|
|
// custom menu and menu item - the slot is in the class kde4appView
|
|
KAction *custom = new KAction(KIcon("colorize"), i18n("Swi&tch Colors"), this);
|
|
actionCollection()->addAction( QLatin1String("switch_action"), custom );
|
|
connect(custom, SIGNAL(triggered(bool)), m_view, SLOT(switchColors()));
|
|
}
|
|
|
|
void kde4app::fileNew()
|
|
{
|
|
// this slot is called whenever the File->New menu is selected,
|
|
// the New shortcut is pressed (usually CTRL+N) or the New toolbar
|
|
// button is clicked
|
|
|
|
// create a new window
|
|
(new kde4app)->show();
|
|
}
|
|
|
|
void kde4app::optionsPreferences()
|
|
{
|
|
// The preference dialog is derived from prefs_base.ui
|
|
//
|
|
// compare the names of the widgets in the .ui file
|
|
// to the names of the variables in the .kcfg file
|
|
//avoid to have 2 dialogs shown
|
|
if ( KConfigDialog::showDialog( "settings" ) ) {
|
|
return;
|
|
}
|
|
KConfigDialog *dialog = new KConfigDialog(this, "settings", Settings::self());
|
|
QWidget *generalSettingsDlg = new QWidget;
|
|
ui_prefs_base.setupUi(generalSettingsDlg);
|
|
dialog->addPage(generalSettingsDlg, i18n("General"), "package_setting");
|
|
connect(dialog, SIGNAL(settingsChanged(QString)), m_view, SLOT(settingsChanged()));
|
|
dialog->setAttribute( Qt::WA_DeleteOnClose );
|
|
dialog->show();
|
|
}
|
|
|
|
#include "moc_kde4app.cpp"
|