Exemplo n.º 1
0
KHTMLImage::KHTMLImage( QWidget *parentWidget,
                        QObject *parent, KHTMLPart::GUIProfile prof )
    : KParts::ReadOnlyPart( parent ), m_image( 0 )
{
    KHTMLPart* parentPart = qobject_cast<KHTMLPart*>( parent );
    setComponentData( KHTMLImageFactory::componentData(), prof == KHTMLPart::BrowserViewGUI && !parentPart );

    KVBox *box = new KVBox( parentWidget );
    box->setAcceptDrops( true );

    m_khtml = new KHTMLPart( box, this, prof );
    m_khtml->setAutoloadImages( true );

    // We do not want our subpart to be destroyed when its widget is,
    // since that may cause all KHTMLParts to die when we're dealing
    // with
    m_khtml->setAutoDeletePart( false );

    connect( m_khtml->view(), SIGNAL(finishedLayout()), this, SLOT(restoreScrollPosition()) );

    setWidget( box );

    // VBox can't take focus, so pass it on to sub-widget
    box->setFocusProxy( m_khtml->widget() );

    m_ext = new KHTMLImageBrowserExtension( this );
    m_ext->setObjectName( "be" );

    m_sbExt = new KParts::StatusBarExtension( this );
    m_sbExt->setObjectName( "sbe" );

    // Remove unnecessary actions.
    delete actionCollection()->action( "setEncoding" );
    delete actionCollection()->action( "viewDocumentSource" );
    delete actionCollection()->action( "selectAll" );

    // forward important signals from the khtml part

    // forward opening requests to parent frame (if existing)
    KHTMLPart *p = qobject_cast<KHTMLPart*>(parent);
    KParts::BrowserExtension *be = p ? p->browserExtension() : m_ext;
    connect(m_khtml->browserExtension(), SIGNAL(openUrlRequestDelayed(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
               be, SIGNAL(openUrlRequestDelayed(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)));

    connect(m_khtml->browserExtension(), SIGNAL(popupMenu(QPoint,KUrl,mode_t,KParts::OpenUrlArguments,KParts::BrowserArguments,KParts::BrowserExtension::PopupFlags,KParts::BrowserExtension::ActionGroupMap)),
            this, SLOT(slotPopupMenu(QPoint,KUrl,mode_t,KParts::OpenUrlArguments,KParts::BrowserArguments,KParts::BrowserExtension::PopupFlags,KParts::BrowserExtension::ActionGroupMap)));

    connect( m_khtml->browserExtension(), SIGNAL(enableAction(const char*,bool)),
             m_ext, SIGNAL(enableAction(const char*,bool)) );

    m_ext->setURLDropHandlingEnabled( true );
}
StatisticsDialog::StatisticsDialog ( StatisticsContact *contact, StatisticsDB *db, QWidget* parent ) : KDialog ( parent ), m_db ( db ), m_contact ( contact )
{
	setAttribute ( Qt::WA_DeleteOnClose, true );
	setButtons ( KDialog::Close );
	setDefaultButton ( KDialog::Close );
	setCaption ( i18n ( "Statistics for %1", contact->metaContact()->displayName() ) );
	QWidget * w = new QWidget ( this );
	dialogUi = new Ui::StatisticsWidgetUI();
	dialogUi->setupUi ( w );
	setMainWidget ( w );


	KHBox *generalHBox = new KHBox ( this );

	generalHTMLPart = new KHTMLPart ( generalHBox );
	connect ( generalHTMLPart->browserExtension(), SIGNAL (openUrlRequestDelayed(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
	          this, SLOT (slotOpenURLRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)) );
	generalHTMLPart->setJScriptEnabled ( false );
	generalHTMLPart->setJavaEnabled ( false );
	generalHTMLPart->setMetaRefreshEnabled ( false );
	generalHTMLPart->setPluginsEnabled ( false );
	generalHTMLPart->setOnlyLocalReferences ( true );

	dialogUi->tabWidget->insertTab ( 0, generalHBox, i18n ( "General" ) );
	dialogUi->tabWidget->setCurrentIndex ( 0 );

	KColorScheme scheme ( QPalette::Active, KColorScheme::View );
	m_onlineColor = scheme.background ( KColorScheme::ActiveBackground ).color().darker(130);
	m_awayColor = scheme.background ( KColorScheme::NeutralBackground ).color().darker(130);
	m_offlineColor = scheme.background ( KColorScheme::AlternateBackground ).color().darker(130);
	m_backgroundColor = scheme.background ( KColorScheme::NormalBackground ).color().darker(130);
	m_textColor = scheme.foreground ( KColorScheme::NormalText ).color();

	calendarHTMLPart = new KHTMLPart ( dialogUi->calendarHBox );
	calendarHTMLPart->setJScriptEnabled ( false );
	calendarHTMLPart->setJavaEnabled ( false );
	calendarHTMLPart->setMetaRefreshEnabled ( false );
	calendarHTMLPart->setPluginsEnabled ( false );
	calendarHTMLPart->setOnlyLocalReferences ( true );

	dialogUi->calendarKey->setTextFormat ( Qt::RichText );
	dialogUi->calendarKey->setText ( i18n ( "Key:  "
	                                        "<font color=\"%1\">Online</font>  "
	                                        "<font color=\"%2\">Away</font>  "
	                                        "<font color=\"%3\">Offline</font>",
	                                        m_onlineColor.name(),
	                                        m_awayColor.name(),
	                                        m_offlineColor.name() ) );

	dialogUi->datePicker->setDate ( QDate::currentDate() );
	connect ( dialogUi->datePicker, SIGNAL (dateChanged(QDate)), this, SLOT (fillCalendarCells()) );
	connect ( dialogUi->datePicker, SIGNAL (dateChanged(QDate)), this, SLOT (generateOneDayStats()) );

	setFocus();
	setEscapeButton ( Close );

	generatePageGeneral();
	fillCalendarCells();
	generateOneDayStats();
}
Exemplo n.º 3
0
bool ArkViewer::viewInInternalViewer(const QString& fileName, const KMimeType::Ptr& mimeType)
{
    const KUrl fileUrl(fileName);

    setCaption(fileUrl.fileName());
    restoreDialogSize(KGlobal::config()->group("Viewer"));

    QFrame *header = new QFrame(m_widget);
    QHBoxLayout *headerLayout = new QHBoxLayout(header);

    QLabel *iconLabel = new QLabel(header);
    headerLayout->addWidget(iconLabel);
    iconLabel->setPixmap(KIconLoader::global()->loadMimeTypeIcon(mimeType->iconName(), KIconLoader::Desktop));
    iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);

    KVBox *headerRight = new KVBox(header);
    headerLayout->addWidget(headerRight);
    new QLabel(QString(QLatin1String( "<qt><b>%1</b></qt>" ))
               .arg(fileUrl.fileName()), headerRight
              );
    new QLabel(mimeType->comment(), headerRight);

    header->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);

    m_part = KMimeTypeTrader::self()->createPartInstanceFromQuery<KParts::ReadOnlyPart>(mimeType->name(),
             m_widget,
             this);

    if (!m_part.data()) {
        return false;
    }

    if (m_part.data()->browserExtension()) {
        connect(m_part.data()->browserExtension(),
                SIGNAL(openUrlRequestDelayed(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
                SLOT(slotOpenUrlRequestDelayed(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)));
    }

    m_part.data()->openUrl(fileUrl);

    return true;
}