Initial implementation of main window + view widget
This commit is contained in:
parent
c1bde86980
commit
1d09d12345
5 changed files with 217 additions and 184 deletions
|
@ -1,8 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||||
<kpartgui name="danbooru_client" version="1">
|
<kpartgui name="danbooru_client" version="3">
|
||||||
|
<ToolBar name="mainToolBar" >
|
||||||
|
<text>Main Toolbar</text>
|
||||||
|
<Action name="connect" />
|
||||||
|
<Action name="fetch" />
|
||||||
|
<Action name="batchDownload" />
|
||||||
|
<Action name="poolDownload" />
|
||||||
|
<Action name="tagDisplay" />
|
||||||
|
<ActionList name="dynamicActionlist" />
|
||||||
|
</ToolBar>
|
||||||
<MenuBar>
|
<MenuBar>
|
||||||
<Menu name="move"><text>&Move</text>
|
<Menu name="file" >
|
||||||
<Action name="switch_action" />
|
<text>&File</text>
|
||||||
|
<Action name="connect" />
|
||||||
|
<Action name="fetch" />
|
||||||
|
<Action name="batchDownload" />
|
||||||
|
<Action name="clean" />
|
||||||
</Menu>
|
</Menu>
|
||||||
</MenuBar>
|
</MenuBar>
|
||||||
</kpartgui>
|
</kpartgui>
|
||||||
|
|
|
@ -17,44 +17,73 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "danbooru_clientview.h"
|
#include "danbooruclientview.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
#include <KLocale>
|
// Own
|
||||||
#include <QtGui/QLabel>
|
|
||||||
|
|
||||||
danbooru_clientView::danbooru_clientView(QWidget *)
|
#include "model/danboorupostmodel.h"
|
||||||
|
#include "model/danboorupostdelegate.h"
|
||||||
|
|
||||||
|
// Qt
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
// KDE
|
||||||
|
|
||||||
|
#include <KRun>
|
||||||
|
#include <KFileDialog>
|
||||||
|
|
||||||
|
namespace Danbooru {
|
||||||
|
|
||||||
|
DanbooruClientView::DanbooruClientView(QWidget * parent): QWidget(parent),
|
||||||
|
m_model(new DanbooruPostModel(this)),
|
||||||
|
m_delegate(0),
|
||||||
|
m_service(0),
|
||||||
|
m_timer(0)
|
||||||
{
|
{
|
||||||
ui_danbooru_clientview_base.setupUi(this);
|
setupUi(this);
|
||||||
settingsChanged();
|
|
||||||
setAutoFillBackground(true);
|
m_delegate = new DanbooruPostDelegate(m_listView);
|
||||||
|
|
||||||
|
m_listView->setFlow(QListView::LeftToRight);
|
||||||
|
m_listView->setResizeMode(QListView::Adjust);
|
||||||
|
m_listView->setWrapping(true);
|
||||||
|
m_listView->setViewMode(QListView::IconMode);
|
||||||
|
m_listView->setGridSize(QSize(256,256));
|
||||||
|
|
||||||
|
m_listView->setModel(m_model);
|
||||||
|
m_listView->setItemDelegate(m_delegate);
|
||||||
|
|
||||||
|
// signal-slot connections
|
||||||
|
|
||||||
|
connect(m_delegate, SIGNAL(postDownloadRequested(KUrl)), this,
|
||||||
|
SLOT(slotHandleDownload(KUrl)));
|
||||||
|
connect(m_delegate, SIGNAL(postViewRequested(KUrl)), this,
|
||||||
|
SLOT(slotHandleView(KUrl)));
|
||||||
|
// connect(m_listView, SIGNAL(clicked(const QModelIndex&)), parent(),
|
||||||
|
// SLOT(displayInfo(const QModelIndex&));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
danbooru_clientView::~danbooru_clientView()
|
DanbooruClientView::~DanbooruClientView()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void danbooru_clientView::switchColors()
|
void DanbooruClientView::slotHandleDownload(KUrl url)
|
||||||
{
|
{
|
||||||
// switch the foreground/background colors of the label
|
// TODO
|
||||||
QColor color = Settings::col_background();
|
Q_UNUSED(url)
|
||||||
Settings::setCol_background( Settings::col_foreground() );
|
|
||||||
Settings::setCol_foreground( color );
|
|
||||||
|
|
||||||
settingsChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void danbooru_clientView::settingsChanged()
|
void DanbooruClientView::slotHandleView(KUrl url)
|
||||||
{
|
{
|
||||||
QPalette pal;
|
KRun* runViewer = new KRun(url, this /*window*/, 0 /*mode*/,
|
||||||
pal.setColor( QPalette::Window, Settings::col_background());
|
false /*isLocalFile*/,
|
||||||
pal.setColor( QPalette::WindowText, Settings::col_foreground());
|
true /*showProgressInfo*/, "" /*asn*/);
|
||||||
ui_danbooru_clientview_base.kcfg_sillyLabel->setPalette( pal );
|
runViewer->setAutoDelete(true);
|
||||||
|
|
||||||
// i18n : internationalization
|
|
||||||
ui_danbooru_clientview_base.kcfg_sillyLabel->setText( i18n("This project is %1 days old",Settings::val_time()) );
|
|
||||||
emit signalChangeStatusbar( i18n("Settings changed") );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "danbooru_clientview.moc"
|
|
||||||
|
} // namespace Danbooru
|
||||||
|
|
|
@ -20,12 +20,19 @@
|
||||||
#ifndef DANBOORU_CLIENTVIEW_H
|
#ifndef DANBOORU_CLIENTVIEW_H
|
||||||
#define DANBOORU_CLIENTVIEW_H
|
#define DANBOORU_CLIENTVIEW_H
|
||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include "ui_danbooruclientview.h"
|
||||||
|
|
||||||
#include "ui_danbooru_clientview_base.h"
|
#include "kurl.h"
|
||||||
|
|
||||||
class QPainter;
|
#include <QWidget>
|
||||||
class KUrl;
|
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
|
namespace Danbooru {
|
||||||
|
|
||||||
|
class DanbooruPostModel;
|
||||||
|
class DanbooruPostDelegate;
|
||||||
|
class DanbooruService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the main view class for danbooru_client. Most of the non-menu,
|
* This is the main view class for danbooru_client. Most of the non-menu,
|
||||||
|
@ -37,37 +44,34 @@ class KUrl;
|
||||||
* @version %{VERSION}
|
* @version %{VERSION}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class danbooru_clientView : public QWidget, public Ui::danbooru_clientview_base
|
class DanbooruClientView : public QWidget, public Ui::DanbooruClientView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
danbooru_clientView(QWidget *parent);
|
DanbooruClientView(QWidget *parent=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~danbooru_clientView();
|
virtual ~DanbooruClientView();
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void slotHandleDownload(KUrl);
|
||||||
|
void slotHandleView(KUrl);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::danbooru_clientview_base ui_danbooru_clientview_base;
|
DanbooruPostModel* m_model;
|
||||||
|
DanbooruPostDelegate* m_delegate;
|
||||||
|
DanbooruService* m_service;
|
||||||
|
|
||||||
signals:
|
QTimer* m_timer;
|
||||||
/**
|
|
||||||
* Use this signal to change the content of the statusbar
|
|
||||||
*/
|
|
||||||
void signalChangeStatusbar(const QString& text);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this signal to change the content of the caption
|
|
||||||
*/
|
|
||||||
void signalChangeCaption(const QString& text);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void switchColors();
|
|
||||||
void settingsChanged();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Danbooru
|
||||||
|
|
||||||
#endif // danbooru_clientVIEW_H
|
#endif // danbooru_clientVIEW_H
|
||||||
|
|
|
@ -17,13 +17,9 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "danbooru_client.h"
|
#include "mainwindow.h"
|
||||||
#include "danbooru_clientview.h"
|
#include "danbooruclientview.h"
|
||||||
#include "settings.h"
|
#include "model/danboorupostmodel.h"
|
||||||
|
|
||||||
#include <QtGui/QDropEvent>
|
|
||||||
#include <QtGui/QPainter>
|
|
||||||
#include <QtGui/QPrinter>
|
|
||||||
|
|
||||||
#include <KConfigDialog>
|
#include <KConfigDialog>
|
||||||
#include <KStatusBar>
|
#include <KStatusBar>
|
||||||
|
@ -34,14 +30,14 @@
|
||||||
|
|
||||||
#include <KLocale>
|
#include <KLocale>
|
||||||
|
|
||||||
danbooru_client::danbooru_client()
|
namespace Danbooru {
|
||||||
: KXmlGuiWindow(),
|
|
||||||
m_view(new danbooru_clientView(this)),
|
|
||||||
m_printer(0)
|
|
||||||
{
|
|
||||||
// accept dnd
|
|
||||||
setAcceptDrops(true);
|
|
||||||
|
|
||||||
|
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
|
// tell the KXmlGuiWindow that this is indeed the main widget
|
||||||
setCentralWidget(m_view);
|
setCentralWidget(m_view);
|
||||||
|
|
||||||
|
@ -57,52 +53,42 @@ danbooru_client::danbooru_client()
|
||||||
// mainwindow to automatically save settings if changed: window size,
|
// mainwindow to automatically save settings if changed: window size,
|
||||||
// toolbar position, icon size, etc.
|
// toolbar position, icon size, etc.
|
||||||
setupGUI();
|
setupGUI();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
danbooru_client::~danbooru_client()
|
DanbooruMainWindow::~DanbooruMainWindow()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void danbooru_client::setupActions()
|
void DanbooruMainWindow::setupActions()
|
||||||
{
|
{
|
||||||
KStandardAction::openNew(this, SLOT(fileNew()), actionCollection());
|
// KStandardAction::openNew(this, SLOT(fileNew()), actionCollection());
|
||||||
KStandardAction::quit(qApp, SLOT(closeAllWindows()), 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
|
// KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
|
||||||
// to the names of the variables in the .kcfg file
|
//
|
||||||
//avoid to have 2 dialogs shown
|
// // custom menu and menu item - the slot is in the class DanbooruMainWindowView
|
||||||
if ( KConfigDialog::showDialog( "settings" ) ) {
|
// KAction *custom = new KAction(KIcon("colorize"), i18n("Swi&tch Colors"), this);
|
||||||
return;
|
// actionCollection()->addAction( QLatin1String("switch_action"), custom );
|
||||||
}
|
// connect(custom, SIGNAL(triggered(bool)), m_view, SLOT(switchColors()));
|
||||||
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"
|
void DanbooruMainWindow::connectToBoard()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DanbooruMainWindow::downloadPosts()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DanbooruMainWindow::optionsPreferences()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Danbooru
|
||||||
|
|
||||||
|
#include "DanbooruMainWindow.moc"
|
||||||
|
|
|
@ -23,49 +23,49 @@
|
||||||
|
|
||||||
#include <KXmlGuiWindow>
|
#include <KXmlGuiWindow>
|
||||||
|
|
||||||
#include "ui_prefs_base.h"
|
namespace Danbooru {
|
||||||
|
|
||||||
class danbooru_clientView;
|
class DanbooruClientView;
|
||||||
class QPrinter;
|
class DanbooruService;
|
||||||
class KToggleAction;
|
class DanbooruPostModel;
|
||||||
class KUrl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class serves as the main window for danbooru_client. It handles the
|
* This class serves as the main window for danbooru_client. It handles the
|
||||||
* menus, toolbars and status bars.
|
* menus, toolbars and status bars.
|
||||||
*
|
*
|
||||||
* @short Main window class
|
* @short Main window class
|
||||||
* @author %{AUTHOR} <%{EMAIL}>
|
* @author Luca Beltrame <lbeltrame@kde.org>
|
||||||
* @version %{VERSION}
|
* @version 0.01
|
||||||
*/
|
*/
|
||||||
class danbooru_client : public KXmlGuiWindow
|
class DanbooruMainWindow : public KXmlGuiWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
danbooru_client();
|
DanbooruMainWindow();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Destructor
|
* Default Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~danbooru_client();
|
virtual ~DanbooruMainWindow();
|
||||||
|
|
||||||
private slots:
|
private Q_SLOTS:
|
||||||
void fileNew();
|
void connectToBoard();
|
||||||
|
void downloadPosts();
|
||||||
void optionsPreferences();
|
void optionsPreferences();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupActions();
|
void setupActions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::prefs_base ui_prefs_base ;
|
DanbooruClientView *m_view;
|
||||||
danbooru_clientView *m_view;
|
DanbooruPostModel* m_model;
|
||||||
|
DanbooruService* m_service;
|
||||||
|
|
||||||
|
|
||||||
QPrinter *m_printer;
|
|
||||||
KToggleAction *m_toolbarAction;
|
|
||||||
KToggleAction *m_statusbarAction;
|
|
||||||
};
|
};
|
||||||
|
} // namespace Danbooru
|
||||||
|
|
||||||
#endif // _DANBOORU_CLIENT_H_
|
#endif // _DANBOORU_CLIENT_H_
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue