Import release 2.0alpha2

This commit is contained in:
Mario Fetka
2008-08-10 11:56:25 +00:00
parent 47cc8f14fa
commit 8b3dac7ce6
303 changed files with 78286 additions and 49595 deletions
+198 -95
View File
@@ -17,17 +17,18 @@
#include "kmessinterface.h"
#include "settings/globalsettingsdialog.h"
#include "utils/kmessconfig.h"
#include "utils/kmessshared.h"
#include "kmessapplication.h"
#include "kmessdebug.h"
#include "systemtraywidget.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QPoint>
#include <QSize>
#include <QStringList>
#include <QTimer>
#include <KAction>
#include <KActionMenu>
#include <KConfig>
#include <KGlobal>
@@ -35,13 +36,10 @@
#include <KLocale>
#include <KMenu>
#include <KMenuBar>
#include <KMessageBox>
#include <KRun>
#include <KSelectAction>
#include <KStandardAction>
#include <KStatusBar>
#include <KToggleAction>
#include <KToolBar>
#include <KToolInvocation>
#include <KUrl>
@@ -50,7 +48,7 @@
// The constructor
KMessInterface::KMessInterface( QWidget *parent )
: KMainWindow( parent )
, connectState_(TYPE_ERROR)
, isErrorStatus_(true)
, initialized_(false)
{
}
@@ -105,6 +103,15 @@ void KMessInterface::applicationClosing()
}
// A view pictures mode has been selected from the menu.
void KMessInterface::changedListPictureSize( int /*mode*/ )
{
kDebug() << "not implemented";
}
// A status was selected from the menu.
void KMessInterface::changeStatus( int /*index*/ )
{
@@ -133,19 +140,12 @@ void KMessInterface::showTransferWindow()
void KMessInterface::configureNotifications()
{
// TODO: Re-enable the notification configuration dialog.
// KNotifyConfigWidget::configure(this);
}
// Create the "Actions" menu
void KMessInterface::createActionsMenu()
{
KAction *newAccount, *searchForContact, *searchByInterest;
KMenu *actionsMenu;
KAction *newAccount, *searchForContact, *searchByInterest;
KToggleAction *searchInContactList;
KMenu *actionsMenu;
// Create the menu
actionsMenu = new KMenu( i18n("&Actions"), this );
@@ -153,9 +153,15 @@ void KMessInterface::createActionsMenu()
// Create the "settings" menus
newContact_ = new KAction( KIcon("list-add-user"), i18n("New &Contact"), this );
newGroup_ = new KAction( KIcon("user-group-new"), i18n("New &Group"), this );
searchForContact = new KAction( KIcon("edit-find-user"), i18n("Search for Contact"), this );
searchForContact = new KAction( KIcon("edit-find-user"), i18n("Search for Contact"), this );
searchByInterest = new KAction( KIcon("system-search"), i18n("Search by &Interest"), this );
searchInContactList = new KToggleAction( KIcon("edit-find-user"), i18n("Search in Contact List"), actionCollection_ );
searchInContactList->setShortcut( QKeySequence::fromString( tr( "Ctrl+f" ) ) );
actionCollection_->addAction("edit-find-user", searchInContactList);
newAccount = new KAction( KIcon("user-identity"), i18n("New &Account"), this );
globalSettings_ = new KAction( KIcon("kmess"), i18n("Configure &KMess"), this );
connect( newContact_, SIGNAL( triggered(bool) ),
SLOT( addNewContact() ) );
@@ -165,12 +171,15 @@ void KMessInterface::createActionsMenu()
SLOT( searchForContact() ) );
connect( searchByInterest, SIGNAL( triggered(bool) ),
SLOT( searchForContactByInterest() ) );
connect( searchInContactList, SIGNAL( triggered(bool) ),
SLOT( toggleShowSearchFrame(bool) ) );
connect( newAccount, SIGNAL( triggered(bool) ),
SLOT( createNewAccount() ) );
connect( globalSettings_, SIGNAL( triggered(bool) ),
SLOT( showGlobalSettings() ) );
// preferences-desktop-user
settingsActionMenu_ = new KActionMenu( KIcon("configure"), i18n("Account &Settings"), this );
configureNotifications_ = KStandardAction::configureNotifications( this, SLOT(configureNotifications()), this );
// Plug the items into "settings"
actionsMenu->addAction( newContact_ );
@@ -178,11 +187,11 @@ void KMessInterface::createActionsMenu()
actionsMenu->addSeparator();
actionsMenu->addAction( searchForContact );
actionsMenu->addAction( searchByInterest );
actionsMenu->addAction( searchInContactList );
actionsMenu->addSeparator();
actionsMenu->addAction( newAccount );
actionsMenu->addAction( settingsActionMenu_ );
actionsMenu->addSeparator();
actionsMenu->addAction( configureNotifications_ );
actionsMenu->addAction( globalSettings_ );
// Plug the menu into the menubar
menuBar()->addMenu( actionsMenu );
@@ -225,8 +234,8 @@ void KMessInterface::createConnectMenu()
connect( status_, SIGNAL( triggered(int) ),
this, SLOT( changeStatus(int) ) );
close = KStandardAction::close( this, SLOT( menuClose() ), this );
quit = KStandardAction::quit ( this, SLOT( menuQuit() ), this );
close = KStandardAction::close( this, SLOT( menuClose() ), actionCollection_ );
quit = KStandardAction::quit ( this, SLOT( menuQuit() ), actionCollection_ );
// Plug the items into "connect"
connectMenu->addAction( connectActionMenu_ );
@@ -238,8 +247,8 @@ void KMessInterface::createConnectMenu()
connectMenu->addAction( close );
connectMenu->addAction( quit );
toolBar( "mainToolBar" )->addAction( disconnect_ );
toolBar( "mainToolBar" )->addAction( status_ );
/* toolBar( "mainToolBar" )->addAction( disconnect_ );
toolBar( "mainToolBar" )->addAction( status_ );*/
// Plug the menu into the menubar
menuBar()->addMenu( connectMenu );
@@ -260,7 +269,7 @@ void KMessInterface::createHelpMenu()
helpMenu_ = new KHelpMenu(this, KGlobal::mainComponent().aboutData());
// Create the help menu items
helpContents = KStandardAction::helpContents( this, SLOT( helpContents() ), this );
helpContents = KStandardAction::helpContents( this, SLOT( helpContents() ), actionCollection_ );
aboutKMess = KStandardAction::aboutApp ( this, SLOT( aboutKMess() ), this );
aboutKDE = KStandardAction::aboutKDE ( this, SLOT( aboutKDE() ), this );
@@ -279,11 +288,17 @@ void KMessInterface::createHelpMenu()
// Create the menus
void KMessInterface::createMenus()
{
// ActionCollection to collect the actions with a shortcut
actionCollection_ = new KActionCollection( this, KComponentData() );
// Create the 4 menus
createConnectMenu();
createViewMenu();
createActionsMenu();
createHelpMenu();
// Add collected actions
addActions( actionCollection_->actions() );
}
@@ -291,7 +306,7 @@ void KMessInterface::createMenus()
// Create the "View" menu
void KMessInterface::createViewMenu()
{
QStringList viewModes;
QStringList viewModes, listPictureSizes;
// Create the menu
viewMenu_ = new KMenu( i18n("&View"), this );
@@ -300,16 +315,27 @@ void KMessInterface::createViewMenu()
showAllowedAction_ = new KToggleAction( i18n("Show &Allowed Contacts"), this );
showOfflineAction_ = new KToggleAction( i18n("Show &Offline Contacts"), this );
showRemovedAction_ = new KToggleAction( i18n("Show &Removed Contacts"), this );
showPicturesAction_= new KToggleAction( i18n("Show &Display Pictures"), this );
showEmptyAction_ = new KToggleAction( i18n("Show &Empty Groups"), this );
// The list mode display picture
listPictureSize_ = new KSelectAction( KIcon("view-list-tree"), i18n("Display Pictures Size"), this );
listPictureSizes << i18n( "Do not display" )
<< i18n( "Small" )
<< i18n( "Medium" )
<< i18n( "Large" );
listPictureSize_->setItems( listPictureSizes );
viewMode_ = new KSelectAction( KIcon("view-list-tree"), i18n("&Sort Contacts by"), this );
viewModes << i18n("Group") << i18n("Online/Offline");
viewModes << i18n("Group") // Account::VIEW_BYGROUP
<< i18n("Online/Offline") // Account::VIEW_BYSTATUS
<< i18n("Mixed"); // Account::VIEW_MIXED
viewMode_->setItems(viewModes);
showTransferAction_ = new KAction( KIcon("document-open-remote"), i18n("Show &Transfer Window"), this );
showToolBar_ = new KToggleAction( i18n("Show &Tool bar"), this );
//showToolBar_ = new KToggleAction( i18n("Show &Tool bar"), this );
showStatusBar_ = KStandardAction::showStatusbar( this, SLOT( showStatusBar() ), this );
showMenuBar_ = KStandardAction::showMenubar( this, SLOT( showMenuBar() ), actionCollection_ );
#ifdef KMESS_NETWORK_WINDOW
showNetworkAction_ = new KAction( KIcon("network-workgroup"), i18n("Show &Network Window"), this );
@@ -317,26 +343,29 @@ void KMessInterface::createViewMenu()
#endif
// Connect the actions
connect( showToolBar_, SIGNAL( triggered(bool) ), this, SLOT( showToolBar() ) );
connect( viewMode_, SIGNAL( triggered(int) ), this, SLOT( changeViewMode(int) ) );
connect( showPicturesAction_, SIGNAL( triggered(bool) ), this, SLOT( toggleDisplayPictures(bool) ) );
connect( showAllowedAction_, SIGNAL( triggered(bool) ), this, SLOT( toggleShowAllowed(bool) ) );
connect( showOfflineAction_, SIGNAL( triggered(bool) ), this, SLOT( toggleShowOffline(bool) ) );
connect( showRemovedAction_, SIGNAL( triggered(bool) ), this, SLOT( toggleShowRemoved(bool) ) );
connect( showTransferAction_, SIGNAL( triggered(bool) ), this, SLOT( showTransferWindow() ) );
// connect( showToolBar_, SIGNAL( triggered(bool) ), this, SLOT( showToolBar() ) );
connect( viewMode_, SIGNAL( triggered(int) ), this, SLOT( changeViewMode(int) ) );
connect( listPictureSize_,SIGNAL( triggered(int) ), this, SLOT( changedListPictureSize(int) ) );
connect( showAllowedAction_, SIGNAL( triggered(bool) ), this, SLOT( toggleShowAllowed(bool) ) );
connect( showOfflineAction_, SIGNAL( triggered(bool) ), this, SLOT( toggleShowOffline(bool) ) );
connect( showRemovedAction_, SIGNAL( triggered(bool) ), this, SLOT( toggleShowRemoved(bool) ) );
connect( showEmptyAction_, SIGNAL( triggered(bool) ), this, SLOT( toggleShowEmpty(bool) ) );
connect( showTransferAction_, SIGNAL( triggered(bool) ), this, SLOT( showTransferWindow() ) );
// Plug the items into "view"
viewMenu_->addAction( showAllowedAction_ );
viewMenu_->addAction( showRemovedAction_ );
viewMenu_->addAction( showOfflineAction_ );
viewMenu_->addAction( showEmptyAction_ );
viewMenu_->addSeparator();
viewMenu_->addAction( showPicturesAction_ );
viewMenu_->addAction( listPictureSize_);
viewMenu_->addSeparator();
viewMenu_->addAction( viewMode_ );
viewMenu_->addSeparator();
viewMenu_->addAction( showTransferAction_ );
viewMenu_->addSeparator();
viewMenu_->addAction( showToolBar_ );
// viewMenu_->addAction( showToolBar_ );
viewMenu_->addAction( showMenuBar_ );
viewMenu_->addAction( showStatusBar_ );
#ifdef KMESS_NETWORK_WINDOW
@@ -382,14 +411,15 @@ void KMessInterface::enableMenus(bool connected)
}
status_->setEnabled( connected );
newContact_-> setEnabled( connected );
newGroup_-> setEnabled( connected );
showAllowedAction_->setEnabled( connected );
showOfflineAction_->setEnabled( connected );
showRemovedAction_->setEnabled( connected );
showPicturesAction_->setEnabled( connected );
showProfile_-> setEnabled( connected );
viewMode_-> setEnabled( connected );
newContact_ ->setEnabled( connected );
newGroup_ ->setEnabled( connected );
showAllowedAction_ ->setEnabled( connected );
showOfflineAction_ ->setEnabled( connected );
showRemovedAction_ ->setEnabled( connected );
showEmptyAction_ ->setEnabled( connected );
listPictureSize_->setEnabled( connected );
showProfile_ ->setEnabled( connected );
viewMode_ ->setEnabled( connected );
// showNetworkAction should ALWAYS be enabled!
}
@@ -416,7 +446,7 @@ bool KMessInterface::initialize()
}
// Initialize the status bar
statusLabel_ = new QLabel( this );
statusLabel_ = new KSqueezedTextLabel( this );
statusBar()->addWidget( statusLabel_, 2 );
statusTimer_ = new QLabel( this );
@@ -477,6 +507,7 @@ bool KMessInterface::initSystemTrayWidget()
menu->addAction( status_ );
menu->addSeparator();
menu->addAction( settingsActionMenu_ );
menu->addAction( globalSettings_ );
// Make the connections for the system tray widget
connect( systemTrayWidget_, SIGNAL( quitSelected() ),
@@ -608,29 +639,49 @@ void KMessInterface::readProperties( const KConfigGroup &config )
kDebug() << "Reading properties";
#endif
KConfigGroup group;
// Choose the config group if it was not given
if( &config == 0 )
{
group = KMessConfig::instance()->getGlobalConfig( "ContactListWindow" );
}
else
{
group = config;
}
// Pull in the window size and position
QSize windowsize = config.readEntry( "Size", QSize() );
QSize windowsize = group.readEntry( "Size", QSize() );
if(!windowsize.isEmpty())
{
resize(windowsize);
}
QPoint position = config.readEntry( "Position", QPoint() );
QPoint position = group.readEntry( "Position", QPoint() );
if(!position.isNull())
{
move(position);
}
// bar status settings
bool bViewToolbar = config.readEntry( "Show Toolbar", true );
bool bViewMenubar = group.readEntry( "Show Menubar", true );
showMenuBar_->setChecked( bViewMenubar );
menuBar()->setVisible( bViewMenubar );
// Commented for future work
/* // bar status settings
bool bViewToolbar = group.readEntry( "Show Toolbar", true );
showToolBar_->setChecked(bViewToolbar);
showToolBar();
*/
bool bViewStatusbar = config.readEntry( "Show Statusbar", true );
showStatusBar_->setChecked(bViewStatusbar);
bool bViewStatusbar = group.readEntry( "Show Statusbar", true );
showStatusBar_->setChecked( bViewStatusbar );
showStatusBar();
// bar position settings
KConfigGroup mainToolBarConfig = config.group( "mainToolBar" );
toolBar( "mainToolBar" )->applySettings( mainToolBarConfig );
/* KConfigGroup mainToolBarGroup = group.group( "mainToolBar" );
toolBar( "mainToolBar" )->applySettings( mainToolBarGroup );
toolBar( "mainToolBar" )->setToolBarsLocked( group.readEntry( "Lock Toolbar", false ) );*/
}
@@ -642,14 +693,28 @@ void KMessInterface::saveProperties(KConfigGroup &config)
kDebug() << "Saving properties";
#endif
config.writeEntry("Size", size() );
config.writeEntry("Position", pos() );
config.writeEntry("Show Toolbar", showToolBar_->isChecked() );
config.writeEntry("Show Statusbar", showStatusBar_->isChecked() );
KConfigGroup group;
// Choose the config group if it was not given
if( &config == 0 )
{
group = KMessConfig::instance()->getGlobalConfig( "ContactListWindow" );
}
else
{
group = config;
}
group.writeEntry("Size", size() );
group.writeEntry("Position", pos() );
// group.writeEntry("Show Toolbar", showToolBar_->isChecked() );
group.writeEntry("Show Menubar", showMenuBar_->isChecked());
group.writeEntry("Show Statusbar", showStatusBar_->isChecked() );
// save the toolbar settings
KConfigGroup mainToolBarConfig = config.group( "mainToolBar" );
toolBar( "mainToolBar" )->saveSettings( mainToolBarConfig );
/* KConfigGroup mainToolBarGroup = group.group( "mainToolBar" );
toolBar( "mainToolBar" )->saveSettings( mainToolBarGroup );
group.writeEntry("Lock Toolbar", toolBar( "mainToolBar" )->toolBarsLocked());*/
#ifdef KMESSDEBUG_KMESSINTERFACE
kDebug() << "Done saving properties";
@@ -661,8 +726,8 @@ void KMessInterface::saveProperties(KConfigGroup &config)
// Open up the URL for MSN's contact search page.
void KMessInterface::searchForContact()
{
// KRun auto-deletes itself.
new KRun( KUrl( "http://members.msn.com/find.msnw?mkt=" + KGlobal::locale()->country() ), window() );
// Launch the browser for the given URL
KMessShared::openBrowser( KUrl( "http://members.msn.com/find.msnw?mkt=" + KGlobal::locale()->country() ) );
}
@@ -670,8 +735,34 @@ void KMessInterface::searchForContact()
// Open up the URL to MSN's "search by interest" page.
void KMessInterface::searchForContactByInterest()
{
// KRun auto-deletes itself.
new KRun( KUrl( "http://members.msn.com/rootcat.msnw?mkt=" + KGlobal::locale()->country() ), window() );
// Launch the browser for the given URL
KMessShared::openBrowser( KUrl( "http://members.msn.com/rootcat.msnw?mkt=" + KGlobal::locale()->country() ) );
}
// The "Show Global Settings" option was clicked.
void KMessInterface::showGlobalSettings()
{
GlobalSettingsDialog *globalSettingsDialog = GlobalSettingsDialog::instance();
globalSettingsDialog->show();
globalSettingsDialog->raise();
}
// "Show menu bar" was toggled.
void KMessInterface::showMenuBar()
{
if( ! showMenuBar_->isChecked() )
{
menuBar()->hide();
}
else
{
menuBar()->show();
}
}
@@ -692,7 +783,7 @@ void KMessInterface::showStatusBar()
// "Show toolbar" was toggled.
void KMessInterface::showToolBar()
/*void KMessInterface::showToolBar()
{
if(!showToolBar_->isChecked())
{
@@ -702,7 +793,7 @@ void KMessInterface::showToolBar()
{
toolBar("mainToolBar")->show();
}
}
}*/
@@ -715,40 +806,36 @@ void KMessInterface::showUserProfile()
// Change the status bar message.
void KMessInterface::statusMessage( QString message, ConnectionStatus connectState )
void KMessInterface::statusMessage( QString message, bool isError )
{
#ifdef KMESSDEBUG_KMESSINTERFACE
kDebug() << "Changed message to" << message;
#endif
statusLabel_->setText( message );
if ( connectState != connectState_ )
if( message != message_ )
{
switch ( connectState )
{
case TYPE_MESSAGE:
onlineTime_ = 0;
onlineTimer_->start( 60000 );
break;
case TYPE_WARNING: // No actions are needed for the warning messages
break;
case TYPE_ERROR:
onlineTimer_->stop();
statusTimer_->setText( "00:00" );
break;
}
statusLabel_->setText( message );
message_ = message;
connectState_ = connectState;
#ifdef KMESSDEBUG_KMESSINTERFACE
kDebug() << "Changed message to" << message;
#endif
}
}
// Do not alter the online timer when the status has not changed
if( isError == isErrorStatus_ )
{
return;
}
if( isError )
{
onlineTimer_->stop();
statusTimer_->setText( "00:00" );
}
else
{
onlineTime_ = 0;
onlineTimer_->start( 60000 );
}
// The "show display pictures" menu item has been toggled.
void KMessInterface::toggleDisplayPictures(bool /*show*/)
{
kDebug() << "not implemented";
isErrorStatus_ = isError;
}
@@ -761,6 +848,22 @@ void KMessInterface::toggleShowAllowed(bool /*show*/)
// The "show empty groups" menu item has been toggled.
void KMessInterface::toggleShowEmpty(bool /*show*/)
{
kDebug() << "not implemented";
}
// The "show search in contact list" menu item has been toggled.
void KMessInterface::toggleShowSearchFrame(bool /*show*/)
{
kDebug() << "not implemented";
}
// The "show offline contacts" menu item has been toggled.
void KMessInterface::toggleShowOffline(bool /*show*/)
{