Initial implementation of main window + view widget

This commit is contained in:
Luca Beltrame 2013-07-28 18:14:55 +02:00
parent c1bde86980
commit 1d09d12345
5 changed files with 217 additions and 184 deletions

View file

@ -17,13 +17,9 @@
* 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 "mainwindow.h"
#include "danbooruclientview.h"
#include "model/danboorupostmodel.h"
#include <KConfigDialog>
#include <KStatusBar>
@ -34,75 +30,65 @@
#include <KLocale>
danbooru_client::danbooru_client()
: KXmlGuiWindow(),
m_view(new danbooru_clientView(this)),
m_printer(0)
{
// accept dnd
setAcceptDrops(true);
namespace Danbooru {
// tell the KXmlGuiWindow that this is indeed the main widget
setCentralWidget(m_view);
DanbooruMainWindow::DanbooruMainWindow()
: KXmlGuiWindow(),
m_view(new DanbooruClientView(this)),
m_service(0),
m_model(new(DanbooruPostModel(this)))
{
// tell the KXmlGuiWindow that this is indeed the main widget
setCentralWidget(m_view);
// then, setup our actions
setupActions();
// then, setup our actions
setupActions();
// add a status bar
statusBar()->show();
// 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;
// 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();
}
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"
DanbooruMainWindow::~DanbooruMainWindow()
{
}
void DanbooruMainWindow::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 DanbooruMainWindowView
// 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 DanbooruMainWindow::connectToBoard()
{
}
void DanbooruMainWindow::downloadPosts()
{
}
void DanbooruMainWindow::optionsPreferences()
{
}
} // namespace Danbooru
#include "DanbooruMainWindow.moc"