Example #1
0
void KonqSideBarWebModule::setAutoReload(){
	KDialogBase dlg(0, "", true, i18n("Set Refresh Timeout (0 disables)"),
			KDialogBase::Ok|KDialogBase::Cancel);
	TQHBox *hbox = dlg.makeHBoxMainWidget();
	
	TQSpinBox *mins = new TQSpinBox( 0, 120, 1, hbox );
	mins->setSuffix( i18n(" min") );
	TQSpinBox *secs = new TQSpinBox( 0, 59, 1, hbox );
	secs->setSuffix( i18n(" sec") );

	if( reloadTimeout > 0 )	{
		int seconds = reloadTimeout / 1000;
		secs->setValue( seconds % 60 );
		mins->setValue( ( seconds - secs->value() ) / 60 );
	}
	
	if( dlg.exec() == TQDialog::Accepted ) {
		int msec = ( mins->value() * 60 + secs->value() ) * 1000;
		reloadTimeout = msec;
		KSimpleConfig ksc(_desktopName);
		ksc.setGroup("Desktop Entry");
		ksc.writeEntry("Reload", reloadTimeout);	
		reload();
	}
}
Example #2
0
void KonqSideBarWebModule::setTitle(const TQString& title) {
	if (!title.isEmpty()) {
		emit setCaption(title);

		KSimpleConfig ksc(_desktopName);
		ksc.setGroup("Desktop Entry");
		if (title != ksc.readPathEntry("Name")) {
			ksc.writePathEntry("Name", title);
		}
	}
}
Example #3
0
void starter::updateShortcutButton(const QString & category)
{
   ShortcutList::Iterator it;
   for ( it = shortcutList.begin(); it != shortcutList.end(); ++it )
      if (it.data() == category)
      {
         QKeyEvent qke( QEvent::KeyPress, it.key().key(), 0, it.key().modFlags());
         KKey kkey(&qke);
         KShortcut ksc(kkey);
         configDialog->buttonShortcut->setShortcut(ksc, false);
         return;
      }
   configDialog->buttonShortcut->setShortcut(KShortcut::null(), false);
}
Example #4
0
void KonqSideBarWebModule::loadFavicon() {
	TQString icon = KonqPixmapProvider::iconForURL(_url.url());
	if (icon.isEmpty()) {
		KonqFavIconMgr::downloadHostIcon(_url);
		icon = KonqPixmapProvider::iconForURL(_url.url());
	}

	if (!icon.isEmpty()) {
		emit setIcon(icon);

		KSimpleConfig ksc(_desktopName);
		ksc.setGroup("Desktop Entry");
		if (icon != ksc.readPathEntry("Icon")) {
			ksc.writePathEntry("Icon", icon);
		}
	}
}
Example #5
0
void KonqSidebarTree::loadModuleFactories()
{
  pluginFactories.clear();
  pluginInfo.clear();
  KStandardDirs *dirs=KGlobal::dirs();
  QStringList list=dirs->findAllResources("data","konqsidebartng/dirtree/*.desktop",false,true);


  for (QStringList::ConstIterator it=list.begin();it!=list.end();++it)
  {
    KSimpleConfig ksc(*it);
    ksc.setGroup("Desktop Entry");
    QString name    = ksc.readEntry("X-KDE-TreeModule");
    QString libName = ksc.readEntry("X-KDE-TreeModule-Lib");
    if ((name.isEmpty()) || (libName.isEmpty()))
        {kdWarning()<<"Bad Configuration file for a dirtree module "<<*it<<endl; continue;}

    //Register the library info.
    pluginInfo[name] = libName;
  }
}
Example #6
0
KonqSideBarWebModule::KonqSideBarWebModule(TDEInstance *instance, TQObject *parent, TQWidget *widgetParent, TQString &desktopName, const char* name)
	: KonqSidebarPlugin(instance, parent, widgetParent, desktopName, name)
{
	_htmlPart = new TDEHTMLSideBar(universalMode());
	connect(_htmlPart, TQT_SIGNAL(reload()), this, TQT_SLOT(reload()));
	connect(_htmlPart, TQT_SIGNAL(completed()), this, TQT_SLOT(pageLoaded()));
	connect(_htmlPart,
		TQT_SIGNAL(setWindowCaption(const TQString&)),
		this,
		TQT_SLOT(setTitle(const TQString&)));
	connect(_htmlPart,
		TQT_SIGNAL(openURLRequest(const TQString&, KParts::URLArgs)),
		this,
		TQT_SLOT(urlClicked(const TQString&, KParts::URLArgs)));
	connect(_htmlPart->browserExtension(),
		TQT_SIGNAL(openURLRequest(const KURL&, const KParts::URLArgs&)),
		this,
		TQT_SLOT(formClicked(const KURL&, const KParts::URLArgs&)));
	connect(_htmlPart,
		TQT_SIGNAL(setAutoReload()), this, TQT_SLOT( setAutoReload() ));
	connect(_htmlPart,
		TQT_SIGNAL(openURLNewWindow(const TQString&, KParts::URLArgs)),
		this,
		TQT_SLOT(urlNewWindow(const TQString&, KParts::URLArgs)));
	connect(_htmlPart,
		TQT_SIGNAL(submitFormRequest(const char*,const TQString&,const TQByteArray&,const TQString&,const TQString&,const TQString&)),
		this,
		TQT_SIGNAL(submitFormRequest(const char*,const TQString&,const TQByteArray&,const TQString&,const TQString&,const TQString&)));

	_desktopName = desktopName;

	KSimpleConfig ksc(_desktopName);
	ksc.setGroup("Desktop Entry");
        reloadTimeout = ksc.readNumEntry("Reload", 0);
	_url = ksc.readPathEntry("URL");
	_htmlPart->openURL(_url );
	// Must load this delayed
	TQTimer::singleShot(0, this, TQT_SLOT(loadFavicon()));
}
Example #7
0
void Sidebar_Widget::buttonPopupActivate(int id)
{
	switch (id)
	{
		case 1:
		{
			KIconDialog kicd(this);
//			kicd.setStrictIconSize(true);
			QString iconname=kicd.selectIcon(KIcon::Small);
			kdDebug()<<"New Icon Name:"<<iconname<<endl;
			if (!iconname.isEmpty())
			{
				KSimpleConfig ksc(m_path+m_currentButton->file);
				ksc.setGroup("Desktop Entry");
				ksc.writeEntry("Icon",iconname);
				ksc.sync();
			        QTimer::singleShot(0,this,SLOT(updateButtons()));
			}
			break;
		}
		case 2:
		{
                        KURLRequesterDlg * dlg = new KURLRequesterDlg( m_currentButton->URL, i18n("Enter a URL:"), this, "url_dlg" );
                        dlg->fileDialog()->setMode( KFile::Directory );
			if (dlg->exec())
			{
				KSimpleConfig ksc(m_path+m_currentButton->file);
				ksc.setGroup("Desktop Entry");
                                if ( !dlg->selectedURL().isValid())
                                {
                                    KMessageBox::error(this, i18n("<qt><b>%1</b> does not exist</qt>").arg(dlg->selectedURL().url()));
                                }
                                else
                                {
                                    QString newurl= dlg->selectedURL().prettyURL();
                                    //If we are going to set the name by 'set name', we don't set it here.
                                    //ksc.writeEntry("Name",newurl);
                                    ksc.writePathEntry("URL",newurl);
                                    ksc.sync();
                                    QTimer::singleShot(0,this,SLOT(updateButtons()));
                                }
			}
                        delete dlg;
			break;
		}
		case 3:
		{
			if (KMessageBox::warningContinueCancel(this,i18n("<qt>Do you really want to remove the <b>%1</b> tab?</qt>").arg(m_currentButton->displayName),
                            QString::null,KStdGuiItem::del())==KMessageBox::Continue)
			{
				QFile f(m_path+m_currentButton->file);
				if (!f.remove())
					qDebug("Error, file not deleted");
				QTimer::singleShot(0,this,SLOT(updateButtons()));
			}
			break;
		}
		case 4: // Set a name for this sidebar tab
		{
			bool ok;
			
			// Pop up the dialog asking the user for name.
			const QString name = KInputDialog::getText(i18n("Set Name"), i18n("Enter the name:"),
			        m_currentButton->displayName, &ok, this);
			
			if(ok)
			{
				// Write the name in the .desktop file of this side button.
				KSimpleConfig ksc(m_path+m_currentButton->file);
				ksc.setGroup("Desktop Entry");
				ksc.writeEntry("Name", name, true, false, true /*localized*/ );
				ksc.sync();
				
				// Update the buttons with a QTimer (why?)
				QTimer::singleShot(0,this,SLOT(updateButtons()));
			}
			break;
		}
	}
}