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">
|
||||
<kpartgui name="danbooru_client" version="1">
|
||||
<MenuBar>
|
||||
<Menu name="move"><text>&Move</text>
|
||||
<Action name="switch_action" />
|
||||
<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>
|
||||
<Menu name="file" >
|
||||
<text>&File</text>
|
||||
<Action name="connect" />
|
||||
<Action name="fetch" />
|
||||
<Action name="batchDownload" />
|
||||
<Action name="clean" />
|
||||
</Menu>
|
||||
</MenuBar>
|
||||
</MenuBar>
|
||||
</kpartgui>
|
||||
|
|
|
@ -17,44 +17,73 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#include "danbooru_clientview.h"
|
||||
#include "settings.h"
|
||||
#include "danbooruclientview.h"
|
||||
|
||||
#include <KLocale>
|
||||
#include <QtGui/QLabel>
|
||||
// Own
|
||||
|
||||
danbooru_clientView::danbooru_clientView(QWidget *)
|
||||
{
|
||||
ui_danbooru_clientview_base.setupUi(this);
|
||||
settingsChanged();
|
||||
setAutoFillBackground(true);
|
||||
}
|
||||
#include "model/danboorupostmodel.h"
|
||||
#include "model/danboorupostdelegate.h"
|
||||
|
||||
danbooru_clientView::~danbooru_clientView()
|
||||
{
|
||||
// Qt
|
||||
|
||||
}
|
||||
#include <QTimer>
|
||||
|
||||
void danbooru_clientView::switchColors()
|
||||
{
|
||||
// switch the foreground/background colors of the label
|
||||
QColor color = Settings::col_background();
|
||||
Settings::setCol_background( Settings::col_foreground() );
|
||||
Settings::setCol_foreground( color );
|
||||
// KDE
|
||||
|
||||
settingsChanged();
|
||||
}
|
||||
#include <KRun>
|
||||
#include <KFileDialog>
|
||||
|
||||
void danbooru_clientView::settingsChanged()
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor( QPalette::Window, Settings::col_background());
|
||||
pal.setColor( QPalette::WindowText, Settings::col_foreground());
|
||||
ui_danbooru_clientview_base.kcfg_sillyLabel->setPalette( pal );
|
||||
namespace Danbooru {
|
||||
|
||||
// i18n : internationalization
|
||||
ui_danbooru_clientview_base.kcfg_sillyLabel->setText( i18n("This project is %1 days old",Settings::val_time()) );
|
||||
emit signalChangeStatusbar( i18n("Settings changed") );
|
||||
}
|
||||
DanbooruClientView::DanbooruClientView(QWidget * parent): QWidget(parent),
|
||||
m_model(new DanbooruPostModel(this)),
|
||||
m_delegate(0),
|
||||
m_service(0),
|
||||
m_timer(0)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
#include "danbooru_clientview.moc"
|
||||
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&));
|
||||
|
||||
|
||||
}
|
||||
|
||||
DanbooruClientView::~DanbooruClientView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DanbooruClientView::slotHandleDownload(KUrl url)
|
||||
{
|
||||
// TODO
|
||||
Q_UNUSED(url)
|
||||
}
|
||||
|
||||
void DanbooruClientView::slotHandleView(KUrl url)
|
||||
{
|
||||
KRun* runViewer = new KRun(url, this /*window*/, 0 /*mode*/,
|
||||
false /*isLocalFile*/,
|
||||
true /*showProgressInfo*/, "" /*asn*/);
|
||||
runViewer->setAutoDelete(true);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Danbooru
|
||||
|
|
|
@ -20,14 +20,21 @@
|
|||
#ifndef 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;
|
||||
class KUrl;
|
||||
#include <QWidget>
|
||||
|
||||
/**
|
||||
class QTimer;
|
||||
|
||||
namespace Danbooru {
|
||||
|
||||
class DanbooruPostModel;
|
||||
class DanbooruPostDelegate;
|
||||
class DanbooruService;
|
||||
|
||||
/**
|
||||
* This is the main view class for danbooru_client. Most of the non-menu,
|
||||
* non-toolbar, and non-statusbar (e.g., non frame) GUI code should go
|
||||
* here.
|
||||
|
@ -37,37 +44,34 @@ class KUrl;
|
|||
* @version %{VERSION}
|
||||
*/
|
||||
|
||||
class danbooru_clientView : public QWidget, public Ui::danbooru_clientview_base
|
||||
{
|
||||
class DanbooruClientView : public QWidget, public Ui::DanbooruClientView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
danbooru_clientView(QWidget *parent);
|
||||
DanbooruClientView(QWidget *parent=0);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~danbooru_clientView();
|
||||
virtual ~DanbooruClientView();
|
||||
|
||||
private:
|
||||
Ui::danbooru_clientview_base ui_danbooru_clientview_base;
|
||||
private Q_SLOTS:
|
||||
void slotHandleDownload(KUrl);
|
||||
void slotHandleView(KUrl);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* Use this signal to change the content of the statusbar
|
||||
*/
|
||||
void signalChangeStatusbar(const QString& text);
|
||||
private:
|
||||
DanbooruPostModel* m_model;
|
||||
DanbooruPostDelegate* m_delegate;
|
||||
DanbooruService* m_service;
|
||||
|
||||
/**
|
||||
* Use this signal to change the content of the caption
|
||||
*/
|
||||
void signalChangeCaption(const QString& text);
|
||||
QTimer* m_timer;
|
||||
|
||||
private slots:
|
||||
void switchColors();
|
||||
void settingsChanged();
|
||||
};
|
||||
|
||||
} // namespace Danbooru
|
||||
|
||||
#endif // danbooru_clientVIEW_H
|
||||
|
|
|
@ -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,14 +30,14 @@
|
|||
|
||||
#include <KLocale>
|
||||
|
||||
danbooru_client::danbooru_client()
|
||||
: KXmlGuiWindow(),
|
||||
m_view(new danbooru_clientView(this)),
|
||||
m_printer(0)
|
||||
{
|
||||
// accept dnd
|
||||
setAcceptDrops(true);
|
||||
namespace Danbooru {
|
||||
|
||||
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);
|
||||
|
||||
|
@ -57,52 +53,42 @@ danbooru_client::danbooru_client()
|
|||
// 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"
|
||||
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"
|
||||
|
|
|
@ -23,49 +23,49 @@
|
|||
|
||||
#include <KXmlGuiWindow>
|
||||
|
||||
#include "ui_prefs_base.h"
|
||||
namespace Danbooru {
|
||||
|
||||
class danbooru_clientView;
|
||||
class QPrinter;
|
||||
class KToggleAction;
|
||||
class KUrl;
|
||||
class DanbooruClientView;
|
||||
class DanbooruService;
|
||||
class DanbooruPostModel;
|
||||
|
||||
/**
|
||||
/**
|
||||
* This class serves as the main window for danbooru_client. It handles the
|
||||
* menus, toolbars and status bars.
|
||||
*
|
||||
* @short Main window class
|
||||
* @author %{AUTHOR} <%{EMAIL}>
|
||||
* @version %{VERSION}
|
||||
* @author Luca Beltrame <lbeltrame@kde.org>
|
||||
* @version 0.01
|
||||
*/
|
||||
class danbooru_client : public KXmlGuiWindow
|
||||
{
|
||||
class DanbooruMainWindow : public KXmlGuiWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
danbooru_client();
|
||||
DanbooruMainWindow();
|
||||
|
||||
/**
|
||||
* Default Destructor
|
||||
*/
|
||||
virtual ~danbooru_client();
|
||||
virtual ~DanbooruMainWindow();
|
||||
|
||||
private slots:
|
||||
void fileNew();
|
||||
private Q_SLOTS:
|
||||
void connectToBoard();
|
||||
void downloadPosts();
|
||||
void optionsPreferences();
|
||||
|
||||
private:
|
||||
private:
|
||||
void setupActions();
|
||||
|
||||
private:
|
||||
Ui::prefs_base ui_prefs_base ;
|
||||
danbooru_clientView *m_view;
|
||||
private:
|
||||
DanbooruClientView *m_view;
|
||||
DanbooruPostModel* m_model;
|
||||
DanbooruService* m_service;
|
||||
|
||||
QPrinter *m_printer;
|
||||
KToggleAction *m_toolbarAction;
|
||||
KToggleAction *m_statusbarAction;
|
||||
};
|
||||
|
||||
};
|
||||
} // namespace Danbooru
|
||||
|
||||
#endif // _DANBOORU_CLIENT_H_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue