#include "prefs/prefs.h"
-#include "thread/threadview.h"
-#include "thread/threadtabwidget.h"
-
-#include "board/boardview.h"
-#include "board/boardtabwidget.h"
-#include "bbs/bbsview.h"
-#include "bbs/bbstabwidget.h"
-#include "favoriteswindow.h"
-
-#include "write/writetabwidget.h"
+#include "threadview.h"
+#include "threadtabwidget.h"
+#include "boardview.h"
+#include "boardtabwidget.h"
+#include "bbsview.h"
+#include "bbstabwidget.h"
+#include "writetabwidget.h"
+#include "viewmediator.h"
#include "libkita/threadinfo.h"
#include "libkita/favoriteboards.h"
#include "libkita/kitaconfig.h"
#include "libkita/signalcollection.h"
#include "libkita/account.h"
-#include "libkita/imgmanager.h"
#include "libkita/datmanager.h"
#include "libkita/boardmanager.h"
-
-#include "image/imagetabwidget.h"
+#include "libkita/config_xt.h"
+#include "libkita/asciiart.h"
+#include "libkita/abone.h"
#include <qdragobject.h>
#include <qtextcodec.h>
#include <kglobal.h>
KitaMainWindow::KitaMainWindow()
- : KParts::DockMainWindow( 0, "Kita" ),
- m_printer( 0 )
+ : KDockMainWindow( 0, "Kita" )
{
// FIXME: merge *.po
KGlobal::locale() ->insertCatalogue( "kitapart" );
// accept dnd
setAcceptDrops( true );
- // setup imgmanager
- Kita::ImgManager::setup( this );
-
// setup view, dock
setupView();
// load cache
loadCache();
- // load completion
- loadCompletion();
-
// load style sheet
loadStyleSheet();
// load ascii art
- loadAsciiArt();
+ Kita::AsciiArtConfig::self()->readConfig();
+ if ( Kita::AsciiArtConfig::self()->asciiArtList().empty() ) {
+ loadAsciiArt();
+ }
// load abone lists
- loadAboneIDList();
- loadAboneNameList();
- loadAboneWordList();
+ Kita::AboneConfig::self()->readConfig();
+ if ( Kita::AboneConfig::self()->aboneIDList().empty() ) {
+ loadAboneIDList();
+ }
+
+ if ( Kita::AboneConfig::self()->aboneNameList().empty() ) {
+ loadAboneNameList();
+ }
+
+ if ( Kita::AboneConfig::self()->aboneWordList().empty() ) {
+ loadAboneWordList();
+ }
// and a status bar
statusBar() ->show();
m_bbsDock->loadSession();
m_boardDock->loadSession();
m_threadDock->loadSession();
- m_naviDock->loadSession();
- m_imgDock->loadSession();
m_writeDock->loadSession();
QString dockConfigPath = locateLocal( "appdata", "dock.conf" );
KConfig dockConfig( dockConfigPath );
// hide writedock
makeDockInvisible( m_writeDock );
- m_showImgViewAction->setChecked( FALSE );
-
- // hide kitanavi
- makeDockInvisible( m_naviDock );
- m_showNaviAction->setChecked( FALSE );
-
- // hide imageviewer
- makeDockInvisible( m_imgDock );
- m_showImgViewAction->setChecked( FALSE );
-
+ // for compativility
+ loadCompletion();
KitaConfig::readConfig( KGlobal::config() );
+ Kita::Config::self()->readConfig();
+
// apply the saved mainwindow settings, if any, and ask the mainwindow
// to automatically save settings if changed: window size, toolbar
// position, icon size, etc.
setAutoSaveSettings();
- // font
- setFont( KitaConfig::listFont() );
+ // set list font
+ setFont( Kita::Config::font() );
// allow the view to change the statusbar and caption
Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
- connect( signalCollection, SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ),
- SLOT( slotOpenURLRequest( const KURL&, const KParts::URLArgs& ) ) );
-
- connect( signalCollection, SIGNAL( openURLRequestExt(
- const KURL&, const KParts::URLArgs&, QString, int,
- const KURL& ) ),
- SLOT( slotOpenURLRequestExt(
- const KURL& , const KParts::URLArgs&, QString, int,
- const KURL& ) ) );
-
- connect( signalCollection, SIGNAL( setMainCaption( const QString& ) ),
- SLOT( slotSetMainCaption( const QString& ) ) );
-
- connect( signalCollection, SIGNAL( setMainStatusbar( const QString& ) ),
- SLOT( slotSetMainStatusbar( const QString& ) ) );
-
- connect( signalCollection, SIGNAL( setMainURLLine( const KURL& ) ),
- SLOT( setUrl( const KURL& ) ) );
-
- connect( signalCollection, SIGNAL( bookmarked( const QString&, bool ) ),
- SLOT( bookmark( const QString&, bool ) ) );
+ connect( signalCollection, SIGNAL( openURLRequestExt( const KURL&, const QString ) ),
+ SLOT( slotOpenURLRequestExt( const KURL&, const QString ) ) );
connect( this, SIGNAL( favoritesUpdated() ),
signalCollection, SIGNAL( favoritesUpdated() ) );
// update favorite list
emit favoritesUpdated();
- if ( KitaConfig::autoLogin() ) {
+ if ( Kita::Config::autoLogin() ) {
login();
}
}
m_bbsDock->saveSession();
m_boardDock->saveSession();
m_threadDock->saveSession();
- m_naviDock->saveSession();
- m_imgDock->saveSession();
m_writeDock->saveSession();
- saveAboneIDList();
- saveAboneNameList();
- saveAboneWordList();
+ Kita::AboneConfig::self()->writeConfig();
saveStyleSheet();
- saveAsciiArt();
-
- saveCompletion();
+ Kita::AsciiArtConfig::self()->writeConfig();
saveFavoriteBoards();
saveMainWindowSettings( KGlobal::config(), "MainWindow" );
KitaConfig::writeConfig( KGlobal::config() );
+ Kita::Config::self()->writeConfig();
QString dockConfigPath = locateLocal( "appdata", "dock.conf" );
KConfig dockConfig( dockConfigPath );
delete m_bbsDock;
delete m_threadDock;
- delete m_naviDock;
- delete m_imgDock;
delete m_writeDock;
Kita::DatManager::deleteAllDatInfo();
void KitaMainWindow::load( const KURL& url )
{
- QString target;
- // the below code is what you should normally do. in this
- // example case, we want the url to our own. you probably
- // want to use this code instead for your app
-
-#if 0
- // download the contents
- if ( KIO::NetAccess::download( url, target ) ) {
- // set our caption
- setCaption( url );
-
- // load in the file (target is always local)
- loadFile( target );
-
- // and remove the temp file
- KIO::NetAccess::removeTempFile( target );
- }
-#endif
-
setCaption( url.url() );
- // m_view->openURL(url);
-}
-
-void KitaMainWindow::setupActions()
-{
- KStdAction::quit( this, SLOT( close() ), actionCollection() );
- KStdAction::copy( this, SLOT( slotEditCopy() ), actionCollection() );
-
- m_toolbarAction = KStdAction::showToolbar( this,
- SLOT( optionsShowToolbar() ),
- actionCollection() );
-
- m_statusbarAction = KStdAction::showStatusbar( this,
- SLOT( optionsShowStatusbar() ),
- actionCollection() );
-
- m_boardListAction = new KToggleAction( i18n( "Show board list" ),
- 0,
- m_bbsDock,
- SLOT( slotToggleShowHide() ),
- actionCollection(),
- "window_show_board_list" );
-
- m_subjectListAction = new KToggleAction( i18n( "Show subject list" ),
- 0,
- m_boardDock,
- SLOT( slotToggleShowHide() ),
- actionCollection(),
- "window_show_subject_list" );
-
- m_showImgViewAction = new KToggleAction( i18n( "Show Image Viewer" ),
- 0,
- m_imgDock,
- SLOT( slotToggleShowHide() ),
- actionCollection(),
- "window_show_imgviewer" );
-
- m_showNaviAction = new KToggleAction( i18n( "Show KitaNavi" ),
- 0,
- m_naviDock,
- SLOT( slotToggleShowHide() ),
- actionCollection(),
- "window_show_kitanavi" );
-
- m_showWriteDockAction = new KToggleAction( i18n( "Show Write Dock" ),
- 0,
- m_writeDock,
- SLOT( slotToggleShowHide() ),
- actionCollection(),
- "window_show_writedock" );
-
- m_urlLine = new KLineEdit( "", 0 );
-
- new KWidgetAction( m_urlLine,
- i18n( "URL Line" ),
- 0,
- this,
- SLOT( slotURLLine() ),
- actionCollection(), "url_line_action" );
-
- KStdAction::keyBindings( this, SLOT( optionsConfigureKeys() ), actionCollection() );
- KStdAction::configureToolbars( this, SLOT( optionsConfigureToolbars() ), actionCollection() );
- KStdAction::preferences( this, SLOT( optionsPreferences() ), actionCollection() );
-
- /* new KAction( i18n( "Edit Favorites" ),
- 0,
- this,
- SLOT( favoritesEdit() ),
- actionCollection(),
- "favorites_edit" );*/
-
- new KAction( i18n( "Load board list" ),
- 0,
- m_bbsTab,
- SLOT( updateBoardList() ),
- actionCollection(),
- "load_board_list" );
-
- new KAction( i18n( "reset windows" ),
- 0,
- this,
- SLOT( resetWindowsCust() ),
- actionCollection(),
- "reset_wincust" );
-
- new KAction( i18n( "default 1" ),
- 0,
- this,
- SLOT( resetWindowsDef1() ),
- actionCollection(),
- "reset_windef1" );
-
- new KAction( i18n( "default 2" ),
- 0,
- this,
- SLOT( resetWindowsDef2() ),
- actionCollection(),
- "reset_windef2" );
-
- new KAction( i18n( "default 3" ),
- 0,
- this,
- SLOT( resetWindowsDef3() ),
- actionCollection(),
- "reset_windef3" );
-
- m_toggleViewAction = new KAction(
- i18n( "&Toggle subject view and thread view" ),
- KShortcut( Qt::Key_F7 ),
- this,
- SLOT( windowToggleView() ),
- actionCollection(),
- "window_toggle_view" );
-
- new KAction( i18n( "Login" ),
- 0,
- this,
- SLOT( login() ),
- actionCollection(),
- "login" );
-
- setXMLFile( "kitaui.rc" );
- KMainWindow::createGUI();
- factory() ->addClient( m_bbsTab );
- factory() ->addClient( m_boardTab );
- factory() ->addClient( m_threadTab );
- factory() ->addClient( m_imgTab );
- factory() ->addClient( m_naviTab );
- factory() ->addClient( m_writeTab );
-}
-
-void KitaMainWindow::slotURLLine()
-{
- KURL url = m_urlLine->text();
- KURL datURL = Kita::getDatURL( url );
- m_threadDock->slotShowThread( datURL, KitaConfig::alwaysUseTab() );
}
-void KitaMainWindow::saveProperties( KConfig* )
+void KitaMainWindow::bookmark( const QString& datURL, bool on )
{
- // the 'config' object points to the session managed
- // config file. anything you write here will be available
- // later when this app is restored
+ FavoriteThreads * favorite = FavoriteThreads::getInstance();
- // if (m_view->currentURL() != QString::null)
- // config->writeEntry("lastURL", m_view->currentURL());
- // KitaConfig::writeConfig( config );
+ if ( on ) {
+ favorite->insert( datURL );
+ } else {
+ favorite->remove( datURL );
+ }
+ saveFavorites();
+ emit favoritesUpdated();
}
-void KitaMainWindow::readProperties( KConfig* )
+void KitaMainWindow::closeSubjectView()
{
- // the 'config' object points to the session managed
- // config file. this function is automatically called whenever
- // the app is being restored. read in here whatever you wrote
- // in 'saveProperties'
-
- // QString url = config->readEntry("lastURL");
-
- // if (url != QString::null)
- // m_view->openURL(KURL(url));
- // KitaConfig::readConfig( config );
+ m_subjectListAction->setChecked( FALSE );
}
-void KitaMainWindow::dragEnterEvent( QDragEnterEvent* event )
+void KitaMainWindow::login()
{
- // accept uri drops only
- event->accept( QUriDrag::canDecode( event ) );
+ if ( Kita::Account::login( Kita::Config::userID(), Kita::Config::password() ) ) {
+ slotSetMainStatusbar( i18n( "Login succeeded." ) );
+ } else {
+ slotSetMainStatusbar( i18n( "Login failed." ) );
+ }
}
-void KitaMainWindow::dropEvent( QDropEvent* event )
+void KitaMainWindow::newToolbarConfig()
{
- // this is a very simplistic implementation of a drop event. we
- // will only accept a dropped URL. the Qt dnd code can do *much*
- // much more, so please read the docs there
- QStrList uri;
-
- // see if we can decode a URI.. if not, just ignore it
- if ( QUriDrag::decode( event, uri ) ) {
- // okay, we have a URI.. process it
- QString url, target;
- url = uri.first();
-
- // load in the file
- load( KURL( url ) );
- }
+ // this slot is called when user clicks "Ok" or "Apply" in the toolbar editor.
+ // recreate our GUI, and re-apply the settings (e.g. "text under icons", etc.)
+ applyMainWindowSettings( KGlobal::config(), "MainWindow" );
}
void KitaMainWindow::optionsShowToolbar()
dlg.exec();
}
-void KitaMainWindow::newToolbarConfig()
-{
- // this slot is called when user clicks "Ok" or "Apply" in the toolbar editor.
- // recreate our GUI, and re-apply the settings (e.g. "text under icons", etc.)
- applyMainWindowSettings( KGlobal::config(), "MainWindow" );
-}
-
-void KitaMainWindow::resetWindowsCust() { resetWindows( 0 ); }
-void KitaMainWindow::resetWindowsDef1() { resetWindows( 1 ); }
-void KitaMainWindow::resetWindowsDef2() { resetWindows( 2 ); }
-void KitaMainWindow::resetWindowsDef3() { resetWindows( 3 ); }
-
-void KitaMainWindow::resetWindows( int pattern )
+void KitaMainWindow::optionsPreferences()
{
- if ( !m_dummyDock || !m_threadDock || !m_bbsDock
- || !m_boardDock || !m_naviDock || !m_imgDock || !m_writeDock ) return ;
-
- makeDockVisible( m_threadDock );
- makeDockVisible( m_bbsDock );
- makeDockVisible( m_boardDock );
- makeDockVisible( m_naviDock );
- makeDockVisible( m_imgDock );
- makeDockVisible( m_writeDock );
-
- makeDockInvisible( m_threadDock );
- makeDockInvisible( m_bbsDock );
- makeDockInvisible( m_boardDock );
- makeDockInvisible( m_naviDock );
- makeDockInvisible( m_imgDock );
- makeDockInvisible( m_writeDock );
-
- m_threadDock->manualDock( m_dummyDock, KDockWidget::DockTop, 100 );
- m_bbsDock->manualDock( m_threadDock, KDockWidget::DockLeft, 20 );
- m_boardDock->manualDock( m_threadDock, KDockWidget::DockTop, 25 );
- m_imgDock->manualDock( m_threadDock, KDockWidget::DockTop, 25 );
- m_writeDock->manualDock( m_threadDock, KDockWidget::DockBottom, 75 );
- m_naviDock->manualDock( m_threadDock, KDockWidget::DockBottom, 50 );
-
- switch ( pattern ) {
-
- /*----------------------------------------*/
- case 0:
-
- /* setSession( docked, tabbed ) */
- m_threadDock ->setSession( TRUE, FALSE );
- m_bbsDock ->setSession( TRUE, FALSE );
- m_boardDock->setSession( TRUE, FALSE );
- m_imgDock ->setSession( TRUE, FALSE );
- m_writeDock ->setSession( TRUE, FALSE );
- m_naviDock ->setSession( TRUE, FALSE );
-
- if ( m_boardListAction ) m_boardListAction->setChecked( TRUE );
- if ( m_subjectListAction ) m_subjectListAction->setChecked( TRUE );
- if ( m_showImgViewAction ) m_showImgViewAction->setChecked( TRUE );
- if ( m_showNaviAction ) m_showNaviAction->setChecked( TRUE );
- if ( m_showWriteDockAction ) m_showWriteDockAction->setChecked( TRUE );
-
- break;
-
- /*----------------------------------------*/
- case 1:
-
- m_imgDock->toDesktop();
- m_writeDock->toDesktop();
- m_naviDock->toDesktop();
-
- makeDockInvisible( m_imgDock );
- makeDockInvisible( m_writeDock );
- makeDockInvisible( m_naviDock );
-
- /* setSession( docked, tabbed ) */
- m_threadDock ->setSession( TRUE, FALSE );
- m_bbsDock ->setSession( TRUE, FALSE );
- m_boardDock->setSession( TRUE, FALSE );
- m_imgDock ->setSession( FALSE, FALSE );
- m_writeDock ->setSession( FALSE, FALSE );
- m_naviDock ->setSession( FALSE, FALSE );
-
- if ( m_boardListAction ) m_boardListAction->setChecked( TRUE );
- if ( m_subjectListAction ) m_subjectListAction->setChecked( TRUE );
- if ( m_showImgViewAction ) m_showImgViewAction->setChecked( FALSE );
- if ( m_showNaviAction ) m_showNaviAction->setChecked( FALSE );
- if ( m_showWriteDockAction ) m_showWriteDockAction->setChecked( FALSE );
-
- break;
-
- /*----------------------------------------*/
- case 2:
-
- m_boardDock->manualDock( m_threadDock, KDockWidget::DockCenter, 0 );
-
- m_imgDock->toDesktop();
- m_writeDock->toDesktop();
- m_naviDock->toDesktop();
-
- makeDockInvisible( m_imgDock );
- makeDockInvisible( m_writeDock );
- makeDockInvisible( m_naviDock );
-
- /* setSession( docked, tabbed ) */
- m_threadDock ->setSession( TRUE, TRUE );
- m_bbsDock ->setSession( TRUE, FALSE );
- m_boardDock->setSession( TRUE, TRUE );
- m_imgDock ->setSession( FALSE, FALSE );
- m_writeDock ->setSession( FALSE, FALSE );
- m_naviDock ->setSession( FALSE, FALSE );
-
- if ( m_boardListAction ) m_boardListAction->setChecked( TRUE );
- if ( m_subjectListAction ) m_subjectListAction->setChecked( TRUE );
- if ( m_showImgViewAction ) m_showImgViewAction->setChecked( FALSE );
- if ( m_showNaviAction ) m_showNaviAction->setChecked( FALSE );
- if ( m_showWriteDockAction ) m_showWriteDockAction->setChecked( FALSE );
-
- break;
-
- /*----------------------------------------*/
- case 3:
-
- m_boardDock->manualDock( m_threadDock, KDockWidget::DockCenter, 0 );
- m_naviDock->manualDock( m_threadDock, KDockWidget::DockCenter, 0 );
- m_imgDock->manualDock( m_threadDock, KDockWidget::DockCenter, 0 );
-
- makeDockInvisible( m_imgDock );
- makeDockInvisible( m_writeDock );
- makeDockInvisible( m_naviDock );
-
- /* setSession( docked, tabbed ) */
- m_threadDock ->setSession( TRUE, TRUE );
- m_bbsDock ->setSession( TRUE, FALSE );
- m_boardDock->setSession( TRUE, TRUE );
- m_imgDock ->setSession( TRUE, TRUE );
- m_writeDock ->setSession( TRUE, FALSE );
- m_naviDock ->setSession( TRUE, TRUE );
-
- if ( m_boardListAction ) m_boardListAction->setChecked( TRUE );
- if ( m_subjectListAction ) m_subjectListAction->setChecked( TRUE );
- if ( m_showImgViewAction ) m_showImgViewAction->setChecked( FALSE );
- if ( m_showNaviAction ) m_showNaviAction->setChecked( FALSE );
- if ( m_showWriteDockAction ) m_showWriteDockAction->setChecked( FALSE );
-
- break;
+ // popup some sort of preference dialog, here
+ if ( KConfigDialog::showDialog( "Kita Preferences" ) ) {
+ return;
}
- m_threadDock->slotShowDock();
-}
+ KitaPreferences* dialog = new KitaPreferences( this );
+ connect( dialog, SIGNAL( fontChanged( const QFont& ) ),
+ SLOT( setFont( const QFont& ) ) );
-void KitaMainWindow::windowToggleView()
-{
- //FIXME: m_boardDock->dockSite() & KDockWidget::DockCenter != 0 igai no toki ha dousuru?
- kdDebug() << "Do toggle" << endl;
- if ( !m_boardDock->isVisible()
- || !m_boardDock->isActiveWindow() ) m_boardDock->slotShowDock();
- else {
- m_threadDock->slotShowDock();
- }
+ dialog->show();
}
void KitaMainWindow::settingsMenuAboutToShow()
m_statusbarAction->setChecked( statusBar() ->isVisible() );
}
-void KitaMainWindow::optionsPreferences()
-{
- // popup some sort of preference dialog, here
- KitaPreferences dlg;
-
- connect( &dlg, SIGNAL( fontChanged( const QFont& ) ),
- SLOT( setFont( const QFont& ) ) );
-
- // XXX
- dlg.setInitialSize( QSize( 600, 400 ) );
- if ( dlg.exec() ) {
- // redo your settings
- }
-}
-
-void KitaMainWindow::slotSetMainStatusbar( const QString& statusStr )
+void KitaMainWindow::setFont( const QFont& font )
{
- // display the text on the statusbar
- statusBar() ->message( statusStr );
+ m_boardTab->setFont( font );
+ m_bbsTab->setFont( font );
}
-void KitaMainWindow::setupView()
+void KitaMainWindow::setUrl( const KURL& url )
{
- /* dummy Main Dock Widget */
- m_dummyDock = createDockWidget( "dummy", 0L, 0L, "dummy", "dummy" );
- m_dummyDock->setDockSite( KDockWidget::DockFullSite );
- m_dummyDock->setEnableDocking( KDockWidget::DockNone );
- setView( m_dummyDock );
- setMainDockWidget( m_dummyDock );
-
- /* Subject View */
- m_boardDock = new KitaBoardDock( manager(), "subject", 0L, 0L, i18n( "subject" ), i18n( "subject" ) );
- m_boardTab = m_boardDock->setup();
- connect( m_boardDock, SIGNAL( checkToggleAction( bool ) ), SLOT( slotCheckSubjectToggleAction( bool ) ) );
-
- /* Board View */
- m_bbsDock = new KitaBBSDock( manager(), "board", 0L, 0L, i18n( "board" ), i18n( "board" ) );
- m_bbsTab = m_bbsDock->setup();
- connect( m_bbsDock, SIGNAL( checkToggleAction( bool ) ), SLOT( slotCheckBoardToggleAction( bool ) ) );
-
- /* Thread View */
- m_threadDock = new KitaThreadDock( manager(), "Thread", 0L, 0L, i18n( "Thread" ), i18n( "Thread" ) );
- m_threadTab = m_threadDock->setupAsMainView();
- m_threadDock->setDockSite( KDockWidget::DockFullSite );
-
- /* KitaNavi */
- m_naviDock = new KitaThreadDock( manager(), "kitanavi", 0L, 0L, i18n( "KitaNavi" ), i18n( "Navi" ) );
- m_naviTab = m_naviDock->setupAsKitaNavi();
- connect( m_naviDock, SIGNAL( checkToggleAction( bool ) ), SLOT( slotCheckNaviToggleAction( bool ) ) );
-
- if ( !KitaConfig::useKitaNavi() ) m_threadDock ->connectNaviSignals();
- else m_naviDock->connectNaviSignals();
-
- /* KitaImgViewer */
- m_imgDock = new KitaImgDock( manager(), "imgviewer", 0L, 0L, i18n( "Kita Image Viewer" ), i18n( "Image" ) );
- m_imgTab = m_imgDock->setup();
- connect( m_imgDock, SIGNAL( checkToggleAction( bool ) ), SLOT( slotCheckImgToggleAction( bool ) ) );
-
- /* write dock */
- m_writeDock = new KitaWriteDock( manager(), "Write", 0L, 0L, i18n( "Write" ), i18n( "Write" ) );
- m_writeTab = m_writeDock->setup();
- connect( m_writeDock, SIGNAL( checkToggleAction( bool ) ), SLOT( slotCheckWriteToggleAction( bool ) ) );
-
- /* reset dock status */
- m_boardListAction = NULL;
- m_subjectListAction = NULL;
- m_showImgViewAction = NULL;
- m_showNaviAction = NULL;
- m_showWriteDockAction = NULL;
- resetWindowsDef1();
+ m_urlLine->setText( url.url() );
}
-void KitaMainWindow::closeSubjectView()
+void KitaMainWindow::windowToggleView()
{
- m_subjectListAction->setChecked( FALSE );
+ //FIXME: m_boardDock->dockSite() & KDockWidget::DockCenter != 0 igai no toki ha dousuru?
+ kdDebug() << "Do toggle" << endl;
+ if ( !m_boardDock->isVisible()
+ || !m_boardDock->isActiveWindow() ) m_boardDock->slotShowDock();
+ else {
+ m_threadDock->slotShowDock();
+ }
}
void KitaMainWindow::slotCheckBoardToggleAction( bool check )
if ( m_subjectListAction ) m_subjectListAction->setChecked( check );
}
-void KitaMainWindow::slotCheckNaviToggleAction( bool check )
-{
- if ( m_showNaviAction ) m_showNaviAction->setChecked( check );
-}
-
-void KitaMainWindow::slotCheckImgToggleAction( bool check )
-{
- if ( m_showImgViewAction ) m_showImgViewAction->setChecked( check );
-}
-
-
void KitaMainWindow::slotCheckWriteToggleAction( bool check )
{
if ( m_showWriteDockAction ) m_showWriteDockAction->setChecked( check );
}
-
-/* open url */ /* public slot */ /* obsolete */
-void KitaMainWindow::slotOpenURLRequest( const KURL& url, const KParts::URLArgs& args )
+void KitaMainWindow::slotEditCopy()
{
- slotOpenURLRequestExt( url, args );
-}
+ QWidget * widget = kapp->focusWidget();
+ if ( widget ) {
+ QKeyEvent e( QEvent::KeyPress, Key_C, 'C', ControlButton );
+ QApplication::sendEvent( widget, &e );
+ }
+}
/* open url */
/*
- If mimetype == "kita_open_2chboard", open the board.
- If mimetype == "kita_open_2chthread", open the thread.
If mimetype == "text/html", open url with web browser.
if mimetype == QString::null, use KIO::NetAccess::mimetype to decide mime type of url.
*/ /* public slot */
-void KitaMainWindow::slotOpenURLRequestExt(
- const KURL& url, const KParts::URLArgs& args,
- QString mimetype,
- int usr1,
- const KURL& usrUrl1 )
+void KitaMainWindow::slotOpenURLRequestExt( const KURL& url, const QString mimetype )
{
- // FIXME: support be.2ch.net
- if ( url.host() == "be.2ch.net" && url.path().contains( "/test/p.php", true ) < 1 ) {
- QMessageBox::warning( this,
- "Kita",
- i18n( "be.2ch.net is currently not supported." ) );
+ /* open url with web browser, etc. */
+ if ( mimetype != QString::null ) {
+ KRun::runURL( url, mimetype );
return ;
}
- kdDebug() << QString( "Requested OpenURL: \"%1\"" ).arg( url.url() ) << endl;
- kdDebug() << QString( "content type: \"%1\"" ).arg( args.contentType() ) << endl;
- kdDebug() << QString( "service type: \"%1\"" ).arg( args.serviceType ) << endl;
- kdDebug() << QString( "NewTab: %1, reload: %2" )
- .arg( args.newTab() ? "yes" : "no" )
- .arg( args.reload ? "yes" : "no" ) << endl;
-
- /* open 2ch board */
- /* if usr1 == 1, open the board with new tab. */
- if ( mimetype == "kita_open_2chboard" ) {
- bool withNewTab = ( usr1 == 1 );
- m_boardDock->slotLoadBoard( url, withNewTab );
+ /* open thread with new thread tab */
+ if ( Kita::DatManager::isThreadEnrolled( url ) ) {
+ m_threadDock->slotShowThread( url );
return ;
}
- /* open 2ch thread */
- /* if usr1 == 1, open the thread with new tab. */
- if ( mimetype == "kita_open_2chthread" ) {
- bool withNewTab = ( usr1 == 1 || usr1 == 2 );
- bool byBackground = ( usr1 == 2 );
- m_threadDock->slotShowThread( url, withNewTab, byBackground );
- return ;
- }
+ QString url_mimetype = KIO::NetAccess::mimetype( url , this );
+ KRun::runURL( url, url_mimetype );
+}
- /* open url with web browser, etc. */
- if ( mimetype != QString::null ) {
- if ( KitaConfig::copyOnClick() ) {
- QClipboard * clipboard = QApplication::clipboard();
- clipboard->setText( url.prettyURL(), QClipboard::Clipboard );
- clipboard->setText( url.prettyURL(), QClipboard::Selection );
- } else {
- KRun::runURL( url, mimetype );
- }
- return ;
- }
+void KitaMainWindow::slotSetMainStatusbar( const QString& statusStr )
+{
+ // display the text on the statusbar
+ statusBar() ->message( statusStr );
+}
- /* open thread with new thread tab */
- if ( Kita::DatManager::isThreadEnrolled( url ) ) {
- m_threadDock->slotShowThread( url, true );
- return ;
- }
+void KitaMainWindow::slotURLLine()
+{
+ KURL url = m_urlLine->text();
+ KURL datURL = Kita::getDatURL( url );
+ m_threadDock->slotShowThread( datURL );
+}
- /* bmp file */
- if ( Kita::ImgManager::isBMP( url ) ) {
- QMessageBox::warning( this,
- "Kita",
- i18n( "This is a BMP file. It might contain a Troy." ) );
- return ;
- }
+//
+// private method
+//
+void KitaMainWindow::setupActions()
+{
+ KStdAction::quit( this, SLOT( close() ), actionCollection() );
+ KStdAction::copy( this, SLOT( slotEditCopy() ), actionCollection() );
- /* open with image viewer */
- /* if usr1 == 0, image viewer is hidden. */
- /* usrUrl1 is datURL. */
- if ( KitaConfig::useImageViewer() ) {
- if ( Kita::ImgManager::isImgFile( url, FALSE ) ) {
+ m_toolbarAction = KStdAction::showToolbar( this,
+ SLOT( optionsShowToolbar() ),
+ actionCollection() );
- if ( !usr1 ) m_imgDock->slotHideDock();
- m_imgDock->slotOpenURL( url, usrUrl1, usr1 );
- return ;
- }
- }
+ m_statusbarAction = KStdAction::showStatusbar( this,
+ SLOT( optionsShowStatusbar() ),
+ actionCollection() );
- if ( mimetype == QString::null ) {
-#if KDE_IS_VERSION( 3, 2, 0 )
- mimetype = KIO::NetAccess::mimetype( url , this );
-#else
- mimetype = KIO::NetAccess::mimetype( url );
-#endif
+ m_boardListAction = new KToggleAction( i18n( "Show board list" ),
+ 0,
+ m_bbsDock,
+ SLOT( slotToggleShowHide() ),
+ actionCollection(),
+ "window_show_board_list" );
- }
- kdDebug() << QString( "queried MIME type: \"%1\"" ).arg( mimetype ) << endl;
-
- /* open with kpart */
- if ( KitaConfig::usePart() ) {
- if ( KitaConfig::partMimeList().find( mimetype ) != KitaConfig::partMimeList().end() ) {
- KService::Ptr service = KServiceTypeProfile::preferredService( mimetype, "KParts/ReadOnlyPart" );
- if ( service ) {
- QString libName = QFile::encodeName( service->library() );
-
- if ( !KitaConfig::useKitaNavi() ) m_threadDock->slotShowPart( url, libName, mimetype );
- else m_naviDock ->slotShowPart( url, libName, mimetype );
- return ;
- }
- }
- }
+ m_subjectListAction = new KToggleAction( i18n( "Show subject list" ),
+ 0,
+ m_boardDock,
+ SLOT( slotToggleShowHide() ),
+ actionCollection(),
+ "window_show_subject_list" );
- if ( KitaConfig::copyOnClick() ) {
- QClipboard * clipboard = QApplication::clipboard();
- clipboard->setText( url.prettyURL(), QClipboard::Clipboard );
- clipboard->setText( url.prettyURL(), QClipboard::Selection );
- } else {
- KRun::runURL( url, mimetype );
- }
+ m_showWriteDockAction = new KToggleAction( i18n( "Show Write Dock" ),
+ 0,
+ m_writeDock,
+ SLOT( slotToggleShowHide() ),
+ actionCollection(),
+ "window_show_writedock" );
+
+ m_urlLine = new KLineEdit( "", 0 );
+
+ new KWidgetAction( m_urlLine,
+ i18n( "URL Line" ),
+ 0,
+ this,
+ SLOT( slotURLLine() ),
+ actionCollection(), "url_line_action" );
+
+ KStdAction::keyBindings( this, SLOT( optionsConfigureKeys() ), actionCollection() );
+ KStdAction::configureToolbars( this, SLOT( optionsConfigureToolbars() ), actionCollection() );
+ KStdAction::preferences( this, SLOT( optionsPreferences() ), actionCollection() );
+
+ new KAction( i18n( "Load board list" ),
+ 0,
+ m_bbsTab,
+ SLOT( updateBoardList() ),
+ actionCollection(),
+ "load_board_list" );
+
+ m_toggleViewAction = new KAction(
+ i18n( "&Toggle subject view and thread view" ),
+ KShortcut( Qt::Key_F7 ),
+ this,
+ SLOT( windowToggleView() ),
+ actionCollection(),
+ "window_toggle_view" );
+
+ new KAction( i18n( "Login" ),
+ 0,
+ this,
+ SLOT( login() ),
+ actionCollection(),
+ "login" );
+
+ setXMLFile( "kitaui.rc" );
+ KMainWindow::createGUI();
+ factory() ->addClient( m_bbsTab );
+ factory() ->addClient( m_boardTab );
+ factory() ->addClient( m_threadTab );
+ factory() ->addClient( m_writeTab );
}
+void KitaMainWindow::setupView()
+{
+ ViewMediator::getInstance()->setMainWindow( this );
+
+ /* dummy Main Dock Widget */
+ m_dummyDock = createDockWidget( "dummy", 0L, 0L, "dummy", "dummy" );
+ m_dummyDock->setDockSite( KDockWidget::DockFullSite );
+ m_dummyDock->setEnableDocking( KDockWidget::DockNone );
+ setView( m_dummyDock );
+ setMainDockWidget( m_dummyDock );
+
+ /* Subject View */
+ m_boardDock = new KitaBoardDock( manager(), "subject", 0L, 0L, i18n( "subject" ), i18n( "subject" ) );
+ m_boardTab = new KitaBoardTabWidget( this, "Subject" );
+ m_boardDock->setWidget( m_boardTab );
+ ViewMediator::getInstance()->setBoardDockWidget( m_boardDock );
+ ViewMediator::getInstance()->setBoardTabWidget( m_boardTab );
+ connect( m_boardDock, SIGNAL( checkToggleAction( bool ) ), SLOT( slotCheckSubjectToggleAction( bool ) ) );
+
+ /* Board View */
+ m_bbsDock = new KitaBBSDock( manager(), "board", 0L, 0L, i18n( "board" ), i18n( "board" ) );
+ m_bbsTab = m_bbsDock->setup();
+ ViewMediator::getInstance()->setBBSDock( m_bbsDock );
+ connect( m_bbsDock, SIGNAL( checkToggleAction( bool ) ), SLOT( slotCheckBoardToggleAction( bool ) ) );
+
+ /* Thread View */
+ m_threadDock = new KitaThreadDock( manager(), "Thread", 0L, 0L, i18n( "Thread" ), i18n( "Thread" ) );
+ m_threadTab = m_threadDock->setupAsMainView();
+ ViewMediator::getInstance()->setThreadDock( m_threadDock );
+ ViewMediator::getInstance()->setThreadTabWidget( m_threadTab );
+ m_threadDock->setDockSite( KDockWidget::DockFullSite );
+
+ /* write dock */
+ m_writeDock = new KitaWriteDock( manager(), "Write", 0L, 0L, i18n( "Write" ), i18n( "Write" ) );
+ m_writeTab = new KitaWriteTabWidget( m_writeDock, "Write View" );
+ m_writeDock->setWidget( m_writeTab );
+ m_writeDock->setWriteTabWidget( m_writeTab );
+ m_writeDock->setup();
+ ViewMediator::getInstance()->setWriteDock( m_writeDock );
+ connect( m_writeDock, SIGNAL( checkToggleAction( bool ) ), SLOT( slotCheckWriteToggleAction( bool ) ) );
+
+ /* reset dock status */
+ m_boardListAction = NULL;
+ m_subjectListAction = NULL;
+ m_showWriteDockAction = NULL;
+}
void KitaMainWindow::loadCache()
{
}
}
-
-/*!
- \fn KitaMainWindow::setFont(QFont& font)
- */
-
-void KitaMainWindow::setFont( const QFont& font )
-{
- m_boardTab->setFont( font );
- m_bbsTab->setFont( font );
-}
-
-
-void KitaMainWindow::setUrl( const KURL& url )
-{
- m_urlLine->setText( url.url() );
-}
-
-void KitaMainWindow::bookmark( const QString& datURL, bool on )
-{
- FavoriteThreads * favorite = FavoriteThreads::getInstance();
-
- if ( on ) {
- favorite->insert( datURL );
- } else {
- favorite->remove( datURL );
- }
- saveFavorites();
- emit favoritesUpdated();
-}
-
void KitaMainWindow::loadFavorites()
{
QString favoritesConfigPath = locateLocal( "appdata", "favorites.xml" );
}
}
-void KitaMainWindow::loadCompletion()
+void KitaMainWindow::loadFavoriteBoards()
{
- QString configPath = locateLocal( "appdata", "completion" );
- KSimpleConfig config( configPath );
+ QString configPath = locateLocal( "appdata", "favorite_boards.xml" );
+ QFile file( configPath );
+ if ( file.open( IO_ReadOnly ) ) {
+ QTextStream stream( &file );
+ stream.setEncoding( QTextStream::UnicodeUTF8 );
- KitaConfig::setNameCompletionItems( config.readListEntry( "name" ) );
+ QString xml = stream.read();
+ Kita::FavoriteBoards::readFromXML( xml );
+ }
+}
+
+void KitaMainWindow::saveFavoriteBoards()
+{
+ QString configPath = locateLocal( "appdata", "favorite_boards.xml" );
+ QFile file( configPath );
+ if ( file.open( IO_WriteOnly ) ) {
+ QTextStream stream( &file );
+ stream.setEncoding( QTextStream::UnicodeUTF8 );
+ stream << Kita::FavoriteBoards::toXML();
+ }
}
-void KitaMainWindow::saveCompletion()
+void KitaMainWindow::loadCompletion()
{
QString configPath = locateLocal( "appdata", "completion" );
KSimpleConfig config( configPath );
- config.writeEntry( "name", KitaConfig::nameCompletion() ->items() );
- config.sync();
+ Kita::Config::setNameCompletionList( config.readListEntry( "name" ) );
}
void KitaMainWindow::loadStyleSheet()
list << str;
}
}
- KitaConfig::setAsciiArtList( list );
- }
-}
-
-void KitaMainWindow::saveAsciiArt()
-{
- QString configPath = locateLocal( "appdata", "asciiart" );
- QFile file( configPath );
- if ( file.open( IO_WriteOnly ) ) {
- QTextStream stream( &file ) ;
- stream.setEncoding( QTextStream::UnicodeUTF8 );
-
- QStringList list = KitaConfig::asciiArtList();
- QStringList::iterator it;
- for ( it = list.begin(); it != list.end(); ++it ) {
- stream << ( *it ) << endl;
- }
- }
-}
-
-void KitaMainWindow::loadFavoriteBoards()
-{
- QString configPath = locateLocal( "appdata", "favorite_boards.xml" );
- QFile file( configPath );
- if ( file.open( IO_ReadOnly ) ) {
- QTextStream stream( &file );
- stream.setEncoding( QTextStream::UnicodeUTF8 );
-
- QString xml = stream.read();
- Kita::FavoriteBoards::readFromXML( xml );
- }
-}
-
-void KitaMainWindow::saveFavoriteBoards()
-{
- QString configPath = locateLocal( "appdata", "favorite_boards.xml" );
- QFile file( configPath );
- if ( file.open( IO_WriteOnly ) ) {
- QTextStream stream( &file );
- stream.setEncoding( QTextStream::UnicodeUTF8 );
- stream << Kita::FavoriteBoards::toXML();
+ Kita::AsciiArtConfig::setAsciiArtList( list );
}
}
list << str;
}
}
- KitaConfig::setAboneIDList( list );
- }
-}
-
-void KitaMainWindow::saveAboneIDList()
-{
- QString configPath = locateLocal( "appdata", "abone_id" );
- QFile file( configPath );
- if ( file.open( IO_WriteOnly ) ) {
- QTextStream stream( &file ) ;
- stream.setEncoding( QTextStream::UnicodeUTF8 );
-
- QStringList list = KitaConfig::aboneIDList();
- QStringList::iterator it;
- for ( it = list.begin(); it != list.end(); ++it ) {
- stream << ( *it ) << endl;
- }
+ Kita::AboneConfig::setAboneIDList( list );
}
}
list << str;
}
}
- KitaConfig::setAboneNameList( list );
- }
-}
-
-void KitaMainWindow::saveAboneNameList()
-{
- QString configPath = locateLocal( "appdata", "abone_name" );
- QFile file( configPath );
- if ( file.open( IO_WriteOnly ) ) {
- QTextStream stream( &file ) ;
- stream.setEncoding( QTextStream::UnicodeUTF8 );
-
- QStringList list = KitaConfig::aboneNameList();
- QStringList::iterator it;
- for ( it = list.begin(); it != list.end(); ++it ) {
- stream << ( *it ) << endl;
- }
+ Kita::AboneConfig::setAboneNameList( list );
}
}
list << str;
}
}
- KitaConfig::setAboneWordList( list );
+ Kita::AboneConfig::setAboneWordList( list );
}
}
-void KitaMainWindow::saveAboneWordList()
-{
- QString configPath = locateLocal( "appdata", "abone_word" );
- QFile file( configPath );
- if ( file.open( IO_WriteOnly ) ) {
- QTextStream stream( &file ) ;
- stream.setEncoding( QTextStream::UnicodeUTF8 );
-
- QStringList list = KitaConfig::aboneWordList();
- QStringList::iterator it;
- for ( it = list.begin(); it != list.end(); ++it ) {
- stream << ( *it ) << endl;
- }
- }
-}
-
-void KitaMainWindow::slotSetMainCaption( const QString& captionStr )
-{
- setCaption( captionStr );
-}
-
-void KitaMainWindow::slotEditCopy()
-{
- QWidget * widget = kapp->focusWidget();
-
- if ( widget ) {
- QKeyEvent e( QEvent::KeyPress, Key_C, 'C', ControlButton );
- QApplication::sendEvent( widget, &e );
- }
-}
-
-void KitaMainWindow::login()
-{
- if ( Kita::Account::login( KitaConfig::userID(), KitaConfig::password() ) ) {
- slotSetMainStatusbar( i18n( "Login succeeded." ) );
- } else {
- slotSetMainStatusbar( i18n( "Login failed." ) );
- }
-}
-
-void KitaMainWindow::favoritesEdit()
-{
- FavoritesWindow * window = new FavoritesWindow( this );
- window->show();
-}
-
#include "mainwindow.moc"