MOve files around, now they start becoming useful

This commit is contained in:
Luca Beltrame 2013-07-28 18:14:33 +02:00
parent 782a113475
commit c1bde86980
4 changed files with 0 additions and 0 deletions

108
src/mainwindow.cpp Normal file
View file

@ -0,0 +1,108 @@
/***************************************************************************
* Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "danbooru_client.h"
#include "danbooru_clientview.h"
#include "settings.h"
#include <QtGui/QDropEvent>
#include <QtGui/QPainter>
#include <QtGui/QPrinter>
#include <KConfigDialog>
#include <KStatusBar>
#include <KAction>
#include <KActionCollection>
#include <KStandardAction>
#include <KLocale>
danbooru_client::danbooru_client()
: KXmlGuiWindow(),
m_view(new danbooru_clientView(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();
}
danbooru_client::~danbooru_client()
{
}
void danbooru_client::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 danbooru_clientView
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 danbooru_client::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 danbooru_client)->show();
}
void danbooru_client::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 "danbooru_client.moc"