diff options
Diffstat (limited to 'src/libs/dialogs')
| -rw-r--r-- | src/libs/dialogs/Makefile.am | 33 | ||||
| -rw-r--r-- | src/libs/dialogs/ctrlpaneldlg.cpp | 445 | ||||
| -rw-r--r-- | src/libs/dialogs/ctrlpaneldlg.h | 110 | ||||
| -rw-r--r-- | src/libs/dialogs/deletedialog.cpp | 309 | ||||
| -rw-r--r-- | src/libs/dialogs/deletedialog.h | 140 | ||||
| -rw-r--r-- | src/libs/dialogs/deletedialogbase.ui | 188 | ||||
| -rw-r--r-- | src/libs/dialogs/dprogressdlg.cpp | 224 | ||||
| -rw-r--r-- | src/libs/dialogs/dprogressdlg.h | 79 | ||||
| -rw-r--r-- | src/libs/dialogs/iccprofileinfodlg.cpp | 60 | ||||
| -rw-r--r-- | src/libs/dialogs/iccprofileinfodlg.h | 58 | ||||
| -rw-r--r-- | src/libs/dialogs/imagedialog.cpp | 366 | ||||
| -rw-r--r-- | src/libs/dialogs/imagedialog.h | 100 | ||||
| -rw-r--r-- | src/libs/dialogs/imagedlgbase.cpp | 261 | ||||
| -rw-r--r-- | src/libs/dialogs/imagedlgbase.h | 98 | ||||
| -rw-r--r-- | src/libs/dialogs/imageguidedlg.cpp | 597 | ||||
| -rw-r--r-- | src/libs/dialogs/imageguidedlg.h | 123 | ||||
| -rw-r--r-- | src/libs/dialogs/rawcameradlg.cpp | 178 | ||||
| -rw-r--r-- | src/libs/dialogs/rawcameradlg.h | 61 | 
18 files changed, 3430 insertions, 0 deletions
| diff --git a/src/libs/dialogs/Makefile.am b/src/libs/dialogs/Makefile.am new file mode 100644 index 00000000..19d50423 --- /dev/null +++ b/src/libs/dialogs/Makefile.am @@ -0,0 +1,33 @@ +METASOURCES = AUTO + +noinst_LTLIBRARIES = libdialog.la libdialogshowfoto.la + +# Dialogs collection used by Showfoto. + +libdialogshowfoto_la_SOURCES = iccprofileinfodlg.cpp imagedialog.cpp rawcameradlg.cpp + +libdialogshowfoto_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_TQT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor + +# Dialogs collection used by digiKam. + +libdialog_la_SOURCES = deletedialogbase.ui imagedialog.cpp rawcameradlg.cpp \ +	                   iccprofileinfodlg.cpp deletedialog.cpp dprogressdlg.cpp  + +libdialog_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_TQT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor + +INCLUDES = -I$(top_srcdir)/src/digikam \ +	       -I$(top_srcdir)/src/libs/dimg \ +	       -I$(top_srcdir)/src/libs/dmetadata \ +	       -I$(top_srcdir)/src/libs/thumbbar \ +	       -I$(top_srcdir)/src/libs/dimg/filters \ +	       -I$(top_srcdir)/src/libs/widgets/common \ +	       -I$(top_srcdir)/src/libs/widgets/metadata \ +	       -I$(top_srcdir)/src/libs/widgets/iccprofiles \ +	       -I$(top_srcdir)/src/libs/widgets/imageplugins \ +	       -I$(top_srcdir)/src/utilities/imageeditor/canvas \ +	       $(LIBKDCRAW_CFLAGS) \ +	       $(LIBKEXIV2_CFLAGS) \ +	       $(all_includes) + +digikaminclude_HEADERS = iccprofileinfodlg.h dprogressdlg.h imagedialog.h rawcameradlg.h  +digikamincludedir = $(includedir)/digikam diff --git a/src/libs/dialogs/ctrlpaneldlg.cpp b/src/libs/dialogs/ctrlpaneldlg.cpp new file mode 100644 index 00000000..450d380f --- /dev/null +++ b/src/libs/dialogs/ctrlpaneldlg.cpp @@ -0,0 +1,445 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2005-05-07 + * Description : A threaded filter control panel dialog for + *               image editor plugins using DImg + * + * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// TQt includes. + +#include <tqvgroupbox.h> +#include <tqlabel.h> +#include <tqpushbutton.h> +#include <tqwhatsthis.h> +#include <tqtooltip.h> +#include <tqlayout.h> +#include <tqframe.h> +#include <tqtimer.h> + +// KDE includes. + +#include <kcursor.h> +#include <tdelocale.h> +#include <tdeaboutdata.h> +#include <khelpmenu.h> +#include <kiconloader.h> +#include <tdeapplication.h> +#include <tdepopupmenu.h> +#include <kstandarddirs.h> +#include <tdeglobalsettings.h> + +// Local includes. + +#include "ddebug.h" +#include "dimgthreadedfilter.h" +#include "dimginterface.h" +#include "ctrlpaneldlg.h" +#include "ctrlpaneldlg.moc" + +namespace Digikam +{ + +class CtrlPanelDlgPriv +{ +public: + +    enum RunningMode +    { +        NoneRendering=0, +        PreviewRendering, +        FinalRendering +    }; +     +    CtrlPanelDlgPriv() +    { +        parent               = 0; +        timer                = 0; +        aboutData            = 0; +        progressBar          = true; +        tryAction            = false; +        currentRenderingMode = NoneRendering; +    } + +    bool         tryAction; +    bool         progressBar; + +    int          currentRenderingMode; + +    TQWidget     *parent; + +    TQTimer      *timer; + +    TQString      name; + +    TDEAboutData  *aboutData; +}; + +CtrlPanelDlg::CtrlPanelDlg(TQWidget* parent, TQString title, TQString name, +                           bool loadFileSettings, bool tryAction, bool progressBar, +                           int separateViewMode, TQFrame* bannerFrame) +            : KDialogBase(Plain, 0, +                          Help|Default|User1|User2|User3|Try|Ok|Cancel, Ok, +                          parent, 0, true, true, +                          i18n("&Abort"), +                          i18n("&Save As..."), +                          i18n("&Load...")) +{ +    kapp->setOverrideCursor( KCursor::waitCursor() ); +    setCaption(DImgInterface::defaultInterface()->getImageFileName() + TQString(" - ") + title); +     +    d = new CtrlPanelDlgPriv; +    d->parent               = parent; +    d->name                 = name; +    d->tryAction            = tryAction; +    d->progressBar          = progressBar; +    m_threadedFilter        = 0; +    TQString whatsThis; + +    setButtonWhatsThis ( Default, i18n("<p>Reset all filter parameters to their default values.") ); +    setButtonWhatsThis ( User1, i18n("<p>Abort the current image rendering.") ); +    setButtonWhatsThis ( User3, i18n("<p>Load all filter parameters from settings text file.") ); +    setButtonWhatsThis ( User2, i18n("<p>Save all filter parameters to settings text file.") ); +    showButton(User2, loadFileSettings); +    showButton(User3, loadFileSettings); +    showButton(Try, tryAction); + +    // disable Abort button on startup +    enableButton(User1, false); + +    resize(configDialogSize(name + TQString(" Tool Dialog"))); +    TQVBoxLayout *topLayout = new TQVBoxLayout( plainPage(), 0, spacingHint()); +     +    // ------------------------------------------------------------- + +    if (bannerFrame) +    { +        bannerFrame->reparent( plainPage(), TQPoint(0, 0) ); +        topLayout->addWidget(bannerFrame); +    } + +    // ------------------------------------------------------------- + +    m_imagePreviewWidget = new ImagePannelWidget(470, 350, name + TQString(" Tool Dialog"), +                               plainPage(), separateViewMode); +    topLayout->addWidget(m_imagePreviewWidget); + +    // ------------------------------------------------------------- + +    TQTimer::singleShot(0, this, TQ_SLOT(slotInit())); +    kapp->restoreOverrideCursor(); +} + +CtrlPanelDlg::~CtrlPanelDlg() +{ +    if (d->aboutData) +       delete d->aboutData; +        +    if (d->timer) +       delete d->timer; + +    if (m_threadedFilter) +       delete m_threadedFilter; + +    delete d; +} + +void CtrlPanelDlg::slotInit() +{ +    // Reset values to defaults. +    TQTimer::singleShot(0, this, TQ_SLOT(readUserSettings())); + +    if (!d->tryAction) +    { +       connect(m_imagePreviewWidget, TQ_SIGNAL(signalOriginalClipFocusChanged()), +               this, TQ_SLOT(slotFocusChanged())); +    } +    else +    { +       connect(m_imagePreviewWidget, TQ_SIGNAL(signalResized()), +               this, TQ_SLOT(slotFocusChanged())); +    } +} + +void CtrlPanelDlg::setAboutData(TDEAboutData *about) +{ +    d->aboutData            = about; +    TQPushButton *helpButton = actionButton( Help ); +    KHelpMenu* helpMenu     = new KHelpMenu(this, d->aboutData, false); +    helpMenu->menu()->removeItemAt(0); +    helpMenu->menu()->insertItem(i18n("digiKam Handbook"), this, TQ_SLOT(slotHelp()), 0, -1, 0); +    helpButton->setPopup( helpMenu->menu() ); +} + +void CtrlPanelDlg::abortPreview() +{ +    d->currentRenderingMode = CtrlPanelDlgPriv::NoneRendering; +    m_imagePreviewWidget->setProgress(0); +    m_imagePreviewWidget->setPreviewImageWaitCursor(false); +    m_imagePreviewWidget->setEnable(true); +    m_imagePreviewWidget->setProgressVisible(false); +    enableButton(Ok,      true); +    enableButton(User1,   false); +    enableButton(User2,   true); +    enableButton(User3,   true); +    enableButton(Try,     true); +    enableButton(Default, true); +    renderingFinished(); +} + +void CtrlPanelDlg::slotTry() +{ +    slotEffect(); +} + +void CtrlPanelDlg::slotUser1() +{ +    if (d->currentRenderingMode != CtrlPanelDlgPriv::NoneRendering) +        if (m_threadedFilter) +           m_threadedFilter->stopComputation(); +} + +void CtrlPanelDlg::slotDefault() +{ +   resetValues(); +   slotEffect(); +} + +void CtrlPanelDlg::slotCancel() +{ +    if (d->currentRenderingMode != CtrlPanelDlgPriv::NoneRendering) +    { +       if (m_threadedFilter) +          m_threadedFilter->stopComputation(); + +       kapp->restoreOverrideCursor(); +    } +     +    saveDialogSize(d->name + TQString(" Tool Dialog")); +    done(Cancel); +} + +void CtrlPanelDlg::closeEvent(TQCloseEvent *e) +{ +    if (d->currentRenderingMode != CtrlPanelDlgPriv::NoneRendering) +    { +       if (m_threadedFilter) +          m_threadedFilter->stopComputation(); + +       kapp->restoreOverrideCursor(); +    } + +    saveDialogSize(d->name + TQString(" Tool Dialog")); +    e->accept(); +} + +void CtrlPanelDlg::slotFocusChanged(void) +{ +    if (d->currentRenderingMode == CtrlPanelDlgPriv::FinalRendering) +    { +       m_imagePreviewWidget->update(); +       return; +    } +    else if (d->currentRenderingMode == CtrlPanelDlgPriv::PreviewRendering) +    { +       if (m_threadedFilter) +          m_threadedFilter->stopComputation(); +    } + +    TQTimer::singleShot(0, this, TQ_SLOT(slotEffect())); +} + +void CtrlPanelDlg::slotHelp() +{ +    // If setAboutData() is called by plugin, well DigikamImagePlugins help is lauched,  +    // else digiKam help. In this case, setHelp() method must be used to set anchor and handbook name. + +    if (d->aboutData) +        TDEApplication::kApplication()->invokeHelp(d->name, "digikam"); +    else +        KDialogBase::slotHelp(); +} + +void CtrlPanelDlg::slotTimer() +{ +    if (d->timer) +    { +       d->timer->stop(); +       delete d->timer; +    } + +    d->timer = new TQTimer( this ); +    connect( d->timer, TQ_SIGNAL(timeout()), +             this, TQ_SLOT(slotEffect()) ); +    d->timer->start(500, true); +} + +void CtrlPanelDlg::slotEffect() +{ +    // Computation already in process. +    if (d->currentRenderingMode != CtrlPanelDlgPriv::NoneRendering) +        return; + +    d->currentRenderingMode = CtrlPanelDlgPriv::PreviewRendering; +    DDebug() << "Preview " << d->name << " started..." << endl; + +    m_imagePreviewWidget->setEnable(false); +    m_imagePreviewWidget->setProgressVisible(true); +    enableButton(Ok,      false); +    enableButton(User1,   true); +    enableButton(User2,   false); +    enableButton(User3,   false); +    enableButton(Try,     false); +    enableButton(Default, false); +    m_imagePreviewWidget->setPreviewImageWaitCursor(true); +    m_imagePreviewWidget->setProgress(0); + +    if (m_threadedFilter) +    { +       delete m_threadedFilter; +       m_threadedFilter = 0; +    } + +    prepareEffect(); +} + +void CtrlPanelDlg::slotOk() +{ +    d->currentRenderingMode = CtrlPanelDlgPriv::FinalRendering; +    DDebug() << "Final " << d->name << " started..." << endl; +    saveDialogSize(d->name + TQString(" Tool Dialog")); +    writeUserSettings(); + +    m_imagePreviewWidget->setEnable(false); +    m_imagePreviewWidget->setProgressVisible(true); +    enableButton(Ok,      false); +    enableButton(User1,   false); +    enableButton(User2,   false); +    enableButton(User3,   false); +    enableButton(Try,     false); +    enableButton(Default, false); +    kapp->setOverrideCursor( KCursor::waitCursor() ); +    m_imagePreviewWidget->setProgress(0); + +    if (m_threadedFilter) +    { +       delete m_threadedFilter; +       m_threadedFilter = 0; +    } + +    prepareFinal(); +} + +void CtrlPanelDlg::customEvent(TQCustomEvent *event) +{ +    if (!event) return; + +    DImgThreadedFilter::EventData *ed = (DImgThreadedFilter::EventData*) event->data(); + +    if (!ed) return; + +    if (ed->starting)           // Computation in progress ! +    { +        m_imagePreviewWidget->setProgress(ed->progress); +    } +    else +    { +        if (ed->success)        // Computation Completed ! +        { +            switch (d->currentRenderingMode) +            { +              case CtrlPanelDlgPriv::PreviewRendering: +              { +                 DDebug() << "Preview " << d->name << " completed..." << endl; +                 putPreviewData(); +                 abortPreview(); +                 break; +              } + +              case CtrlPanelDlgPriv::FinalRendering: +              { +                 DDebug() << "Final" << d->name << " completed..." << endl; +                 putFinalData(); +                 kapp->restoreOverrideCursor(); +                 accept(); +                 break; +              } +            } +        } +        else                   // Computation Failed ! +        { +            switch (d->currentRenderingMode) +            { +                case CtrlPanelDlgPriv::PreviewRendering: +                { +                    DDebug() << "Preview " << d->name << " failed..." << endl; +                    // abortPreview() must be call here for set progress bar to 0 properly. +                    abortPreview(); +                    break; +                } + +                case CtrlPanelDlgPriv::FinalRendering: +                    break; +            } +        } +    } + +    delete ed; +} + +// Backport KDialog::keyPressEvent() implementation from KDELibs to ignore Enter/Return Key events  +// to prevent any conflicts between dialog keys events and SpinBox keys events. + +void CtrlPanelDlg::keyPressEvent(TQKeyEvent *e) +{ +    if ( e->state() == 0 ) +    { +        switch ( e->key() ) +        { +        case Key_Escape: +            e->accept(); +            reject(); +        break; +        case Key_Enter:             +        case Key_Return:      +            e->ignore();               +        break; +        default: +            e->ignore(); +            return; +        } +    } +    else +    { +        // accept the dialog when Ctrl-Return is pressed +        if ( e->state() == ControlButton && +            (e->key() == Key_Return || e->key() == Key_Enter) ) +        { +            e->accept(); +            accept(); +        } +        else +        { +            e->ignore(); +        } +    } +} + +}  // NameSpace Digikam + diff --git a/src/libs/dialogs/ctrlpaneldlg.h b/src/libs/dialogs/ctrlpaneldlg.h new file mode 100644 index 00000000..eb60877e --- /dev/null +++ b/src/libs/dialogs/ctrlpaneldlg.h @@ -0,0 +1,110 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2005-05-07 + * Description : A threaded filter control panel dialog for  + *               image editor plugins using DImg + *  + * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + *  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + *  + * ============================================================ */ + +#ifndef CTRLPANELDLG_H +#define CTRLPANELDLG_H + +// TQt includes + +#include <tqstring.h> + +// KDE include. + +#include <kdialogbase.h> + +// Local includes + +#include "imagepannelwidget.h" +#include "digikam_export.h" + +class TQFrame; + +namespace Digikam +{ + +class CtrlPanelDlgPriv; +class DImgThreadedFilter; + +class DIGIKAM_EXPORT CtrlPanelDlg : public KDialogBase +{ +    TQ_OBJECT +   + +public: + +    CtrlPanelDlg(TQWidget* parent, TQString title, TQString name, +                 bool loadFileSettings=false, bool tryAction=false, bool progressBar=true, +                 int separateViewMode=ImagePannelWidget::SeparateViewAll, +                 TQFrame* bannerFrame=0); +    ~CtrlPanelDlg(); + +    void setAboutData(TDEAboutData *about); + +public: +         +    ImagePannelWidget  *m_imagePreviewWidget; + +    DImgThreadedFilter *m_threadedFilter; +             +public slots:  + +    void slotTimer();        +    void slotEffect(); +    void slotOk(); +    void slotTry(); + +private slots: +     +    virtual void slotDefault(); +    virtual void slotCancel(); +    virtual void slotUser1(); +    virtual void slotInit(); +    virtual void readUserSettings(void){ slotDefault(); }; +      +    void slotHelp(); +    void slotFocusChanged(void);     +     +protected: + +    void closeEvent(TQCloseEvent *e); +    void customEvent(TQCustomEvent *event); +    void abortPreview(void); +    void keyPressEvent(TQKeyEvent *e); + +    virtual void writeUserSettings(void){};             +    virtual void resetValues(void){}; +    virtual void prepareEffect(void){}; +    virtual void prepareFinal(void){}; +    virtual void putPreviewData(void){}; +    virtual void putFinalData(void){}; +    virtual void renderingFinished(void){}; + +private: +     +    CtrlPanelDlgPriv* d; +}; + +}  // NameSpace Digikam + +#endif /* CTRLPANELDLG_H */ diff --git a/src/libs/dialogs/deletedialog.cpp b/src/libs/dialogs/deletedialog.cpp new file mode 100644 index 00000000..1db9b9c4 --- /dev/null +++ b/src/libs/dialogs/deletedialog.cpp @@ -0,0 +1,309 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2005-05-07 + * Description : a dialog to delete item. + *  + * Copyright (C) 2004 by Michael Pyne <michael.pyne@kdemail.net> + * Copyright (C) 2006 by Ian Monroe <ian@monroe.nu> + * Copyright (C) 2006-2007 by Marcel Wiesweg <marcel.wiesweg@gmx.de> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + *  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + *  + * ============================================================ */ + +// TQt includes. + +#include <tqstringlist.h> +#include <tqlayout.h> +#include <tqlabel.h> +#include <tqpushbutton.h> +#include <tqtimer.h> +#include <tqvbox.h> +#include <tqhbox.h> +#include <tqwidgetstack.h> + +// KDE includes. + +#include <tdeconfig.h> +#include <tdeversion.h> +#include <kdialogbase.h> +#include <tdeglobal.h> +#include <kiconloader.h> +#include <tdeio/job.h> +#include <tdelocale.h> +#include <kstdguiitem.h> + +// Local includes. + +#include "deletedialog.h" +#include "albumsettings.h" +#include "deletedialog.moc" + +namespace Digikam +{ + +////////////////////////////////////////////////////////////////////////////// +// DeleteWidget implementation +////////////////////////////////////////////////////////////////////////////// + +DeleteWidget::DeleteWidget(TQWidget *parent, const char *name) +            : DeleteDialogBase(parent, name), +              m_listMode(DeleteDialogMode::Files), +              m_deleteMode(DeleteDialogMode::UseTrash) +{ +    ddCheckBoxStack->raiseWidget(ddShouldDeletePage); + +    bool deleteInstead = !AlbumSettings::instance()->getUseTrash(); +    slotShouldDelete(deleteInstead); +    ddShouldDelete->setChecked(deleteInstead); +} + +void DeleteWidget::setFiles(const KURL::List &files) +{ +    ddFileList->clear(); +    for( KURL::List::ConstIterator it = files.begin(); it != files.end(); it++) +    { +        if( (*it).isLocalFile() ) //path is nil for non-local +            ddFileList->insertItem( (*it).path() ); +        else if ( (*it).protocol() == "digikamalbums") +            ddFileList->insertItem( (*it).path() ); +        else +            ddFileList->insertItem( (*it).prettyURL() ); +    } +    updateText(); +} + +void DeleteWidget::slotShouldDelete(bool shouldDelete) +{ +    setDeleteMode(shouldDelete ? DeleteDialogMode::DeletePermanently : DeleteDialogMode::UseTrash); +} + +void DeleteWidget::setDeleteMode(DeleteDialogMode::DeleteMode deleteMode) +{ +    m_deleteMode = deleteMode; +    updateText(); +} + +void DeleteWidget::setListMode(DeleteDialogMode::ListMode listMode) +{ +    m_listMode = listMode; +    updateText(); +} + +void DeleteWidget::updateText() +{ +    switch (m_listMode) +    { +        case DeleteDialogMode::Files: + +        // Delete files + +        if (m_deleteMode == DeleteDialogMode::DeletePermanently) +        { +            ddDeleteText->setText(i18n("<qt>These items will be <b>permanently " +                                       "deleted</b> from your hard disk.</qt>")); +            ddWarningIcon->setPixmap(TDEGlobal::iconLoader()->loadIcon("messagebox_warning", +                TDEIcon::Desktop, TDEIcon::SizeLarge)); +        } +        else +        { +            ddDeleteText->setText(i18n("<qt>These items will be moved to Trash.</qt>")); +            ddWarningIcon->setPixmap(TDEGlobal::iconLoader()->loadIcon("trashcan_full", +                TDEIcon::Desktop, TDEIcon::SizeLarge)); +        } +        ddNumFiles->setText(i18n("<b>1</b> file selected.", "<b>%n</b> files selected.", ddFileList->count())); +        break; + +        case DeleteDialogMode::Albums: + +        // Delete albums = folders + +        if (m_deleteMode == DeleteDialogMode::DeletePermanently) +        { +            ddDeleteText->setText(i18n("<qt>These albums will be <b>permanently " +                                       "deleted</b> from your hard disk.</qt>")); +            ddWarningIcon->setPixmap(TDEGlobal::iconLoader()->loadIcon("messagebox_warning", +                                     TDEIcon::Desktop, TDEIcon::SizeLarge)); +        } +        else +        { +            ddDeleteText->setText(i18n("<qt>These albums will be moved to Trash.</qt>")); +            ddWarningIcon->setPixmap(TDEGlobal::iconLoader()->loadIcon("trashcan_full", +                                     TDEIcon::Desktop, TDEIcon::SizeLarge)); +        } +        ddNumFiles->setText(i18n("<b>1</b> album selected.", "<b>%n</b> albums selected.", ddFileList->count())); +        break; + +        case DeleteDialogMode::Subalbums: + +        // As above, but display additional warning + +        if (m_deleteMode == DeleteDialogMode::DeletePermanently) +        { +            ddDeleteText->setText(i18n("<qt>These albums will be <b>permanently " +                                       "deleted</b> from your hard disk.<br>" +                                       "Note that <b>all subalbums</b> " +                                       "are included in this list and will " +                                       "be deleted permanently as well.</qt>")); +            ddWarningIcon->setPixmap(TDEGlobal::iconLoader()->loadIcon("messagebox_warning", +                                     TDEIcon::Desktop, TDEIcon::SizeLarge)); +        } +        else +        { +            ddDeleteText->setText(i18n("<qt>These albums will be moved to Trash.<br>" +                                       "Note that <b>all subalbums</b> " +                                       "are included in this list and will " +                                       "be moved to Trash as well.</qt>")); +            ddWarningIcon->setPixmap(TDEGlobal::iconLoader()->loadIcon("trashcan_full", +                                     TDEIcon::Desktop, TDEIcon::SizeLarge)); +        } +        ddNumFiles->setText(i18n("<b>1</b> album selected.", "<b>%n</b> albums selected.", ddFileList->count())); +        break; + +    } +} + +////////////////////////////////////////////////////////////////////////////// +// DeleteDialog implementation +////////////////////////////////////////////////////////////////////////////// + +DeleteDialog::DeleteDialog(TQWidget *parent, const char *name)  +            : KDialogBase(Swallow, WStyle_DialogBorder, parent, name, +                          true, // modal +                          i18n("About to delete selected files"), // caption +                          Ok | Cancel, // available buttons +                          Ok,  // default button +                          true // use separator between buttons and the main widget +                         ), +              m_saveShouldDeleteUserPreference(true), +              m_saveDoNotShowAgain(false), +              m_trashGuiItem(i18n("&Move to Trash"), "trashcan_full") +{ +    m_widget = new DeleteWidget(this, "delete_dialog_widget"); +    setMainWidget(m_widget); + +    m_widget->setMinimumSize(400, 300); +    setMinimumSize(410, 326); +    adjustSize(); + +    slotShouldDelete(shouldDelete()); +    connect(m_widget->ddShouldDelete, TQ_SIGNAL(toggled(bool)), +            this, TQ_SLOT(slotShouldDelete(bool))); + +    actionButton(Ok)->setFocus(); +} + +bool DeleteDialog::confirmDeleteList(const KURL::List& condemnedFiles, +                                     DeleteDialogMode::ListMode listMode, +                                     DeleteDialogMode::DeleteMode deleteMode) +{ +    setURLs(condemnedFiles); +    presetDeleteMode(deleteMode); +    setListMode(listMode); + +    if (deleteMode == DeleteDialogMode::NoChoiceTrash) +    { +        if (!AlbumSettings::instance()->getShowTrashDeleteDialog()) +            return true; +    } +    return exec() == TQDialog::Accepted; +} + +void DeleteDialog::setURLs(const KURL::List &files) +{ +    m_widget->setFiles(files); +} + +void DeleteDialog::accept() +{ +    // Save user's preference +    AlbumSettings *settings = AlbumSettings::instance(); + +    if (m_saveShouldDeleteUserPreference) +    { +        settings->setUseTrash(!shouldDelete()); +    } +    if (m_saveDoNotShowAgain) +    { +        settings->setShowTrashDeleteDialog(!m_widget->ddDoNotShowAgain->isChecked()); +    } + +    settings->saveSettings(); + +    KDialogBase::accept(); +} + +void DeleteDialog::slotShouldDelete(bool shouldDelete) +{ +    // This is called once from constructor, and then when the user changed the checkbox state. +    // In that case, save the user's preference. +    m_saveShouldDeleteUserPreference = true; +    setButtonGuiItem(Ok, shouldDelete ? KStdGuiItem::del() : m_trashGuiItem); +} + +void DeleteDialog::presetDeleteMode(DeleteDialogMode::DeleteMode mode) +{ +    switch (mode) +    { +        case DeleteDialogMode::NoChoiceTrash: +        { +            // access the widget directly, signals will be fired to DeleteDialog and DeleteWidget +            m_widget->ddShouldDelete->setChecked(false); +            m_widget->ddCheckBoxStack->raiseWidget(m_widget->ddDoNotShowAgainPage); +            m_saveDoNotShowAgain = true; +            break; +        } +        case DeleteDialogMode::NoChoiceDeletePermanently: +        { +            m_widget->ddShouldDelete->setChecked(true); +            m_widget->ddCheckBoxStack->hide(); +            break; +        } +        case DeleteDialogMode::UserPreference: +        { +            break; +        } +        case DeleteDialogMode::UseTrash: +        case DeleteDialogMode::DeletePermanently: +        { +            // toggles signals which do the rest +            m_widget->ddShouldDelete->setChecked(mode == DeleteDialogMode::DeletePermanently); + +            // the preference set by this preset method will be ignored +            // for the next DeleteDialog instance and not stored as user preference. +            // Only if the user once changes this value, it will be taken as user preference. +            m_saveShouldDeleteUserPreference = false; +            break; +        } +    } +} + +void DeleteDialog::setListMode(DeleteDialogMode::ListMode mode) +{ +    m_widget->setListMode(mode); +    switch (mode) +    { +        case DeleteDialogMode::Files: +            setCaption(i18n("About to delete selected files")); +            break; + +        case DeleteDialogMode::Albums: +        case DeleteDialogMode::Subalbums: +            setCaption(i18n("About to delete selected albums")); +            break; +    } +} + +} // namespace Digikam diff --git a/src/libs/dialogs/deletedialog.h b/src/libs/dialogs/deletedialog.h new file mode 100644 index 00000000..16ab9f89 --- /dev/null +++ b/src/libs/dialogs/deletedialog.h @@ -0,0 +1,140 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2005-05-07 + * Description : a dialog to delete item. + *  + * Copyright (C) 2004 by Michael Pyne <michael.pyne@kdemail.net> + * Copyright (C) 2006 by Ian Monroe <ian@monroe.nu> + * Copyright (C) 2006-2007 by Marcel Wiesweg <marcel.wiesweg@gmx.de> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + *  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + *  + * ============================================================ */ + +#ifndef _DELETEDIALOG_H +#define _DELETEDIALOG_H + +// TQt includes. + +#include <tqcheckbox.h> + +// KDE includes. + +#include <kdialogbase.h> +#include <kurl.h> + +// Local includes. + +#include "digikam_export.h" +#include "deletedialogbase.h" + +class TQStringList; +class TDEListBox; +class KGuiItem; +class TQLabel; +class TQWidgetStack; + +namespace Digikam +{ + +namespace DeleteDialogMode +{ +    enum ListMode +    { +        Files, +        Albums, +        Subalbums +    }; + +    enum DeleteMode +    { +        NoChoiceTrash, // "Do not show again" checkbox, does not show if config entry is set +        NoChoiceDeletePermanently, // No checkbox +        UserPreference, // Checkbox to toggle trash/permanent, preset to user's last preference +        UseTrash, // same beckbox as above, preset to trash +        DeletePermanently // same checkbox as above, preset to permanent +    }; +} + +class DeleteWidget : public DeleteDialogBase +{ +    TQ_OBJECT +   + +public: + +    DeleteWidget(TQWidget *parent = 0, const char *name = 0); + +    void setFiles(const KURL::List &files); +    void setListMode(DeleteDialogMode::ListMode mode); +    void setDeleteMode(DeleteDialogMode::DeleteMode deleteMode); + +protected slots: + +    void slotShouldDelete(bool shouldDelete); + +protected: + +    void updateText(); +    DeleteDialogMode::ListMode m_listMode; +    DeleteDialogMode::DeleteMode m_deleteMode; +}; + +class DIGIKAM_EXPORT DeleteDialog : public KDialogBase +{ +    TQ_OBJECT +   + +public: + +    enum Mode +    { +        ModeFiles, +        ModeAlbums, +        ModeSubalbums +    }; + +public: + +    DeleteDialog(TQWidget *parent, const char *name = "delete_dialog"); + +    bool confirmDeleteList(const KURL::List &condemnedURLs, +                           DeleteDialogMode::ListMode listMode, +                           DeleteDialogMode::DeleteMode deleteMode); +    bool shouldDelete() const { return m_widget->ddShouldDelete->isChecked(); } + +    void setURLs(const KURL::List &files); +    void presetDeleteMode(DeleteDialogMode::DeleteMode mode); +    void setListMode(DeleteDialogMode::ListMode mode); + +protected slots: + +    virtual void accept(); +    void slotShouldDelete(bool shouldDelete); + +private: + +    bool          m_saveShouldDeleteUserPreference; +    bool          m_saveDoNotShowAgain; + +    KGuiItem      m_trashGuiItem; + +    DeleteWidget *m_widget; +}; + +} // namespace Digikam + +#endif // _DELETEDIALOG_H + diff --git a/src/libs/dialogs/deletedialogbase.ui b/src/libs/dialogs/deletedialogbase.ui new file mode 100644 index 00000000..8527a903 --- /dev/null +++ b/src/libs/dialogs/deletedialogbase.ui @@ -0,0 +1,188 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +	<class>DeleteDialogBase</class> +	<widget class="TQWidget"> +		<property name="name"> +			<cstring>DeleteDialogBase</cstring> +		</property> +		<property name="geometry"> +			<rect> +				<x>0</x> +				<y>0</y> +				<width>517</width> +				<height>162</height> +			</rect> +		</property> +		<property name="caption"> +			<string>DeleteDialogBase</string> +		</property> +		<property name="geometry" stdset="0"> +			<rect> +				<x>0</x> +				<y>0</y> +				<width>542</width> +				<height>374</height> +			</rect> +		</property> +		<property name="minimumSize" stdset="0"> +			<size> +				<width>420</width> +				<height>320</height> +			</size> +		</property> +		<vbox> +			<property name="name"> +				<cstring>unnamed</cstring> +			</property> +			<property name="margin"> +				<number>0</number> +			</property> +			<widget class="TQLayoutWidget"> +				<property name="name"> +					<cstring>layout4</cstring> +				</property> +				<hbox> +					<property name="name"> +						<cstring>unnamed</cstring> +					</property> +					<widget class="TQLabel"> +						<property name="name"> +							<cstring>ddWarningIcon</cstring> +						</property> +						<property name="sizePolicy"> +							<sizepolicy> +								<hsizetype>4</hsizetype> +								<vsizetype>4</vsizetype> +								<horstretch>0</horstretch> +								<verstretch>0</verstretch> +							</sizepolicy> +						</property> +						<property name="text"> +							<string>Icon Placeholder, not in GUI</string> +						</property> +					</widget> +					<widget class="TQLayoutWidget"> +						<property name="name"> +							<cstring>layout3</cstring> +						</property> +						<vbox> +							<property name="name"> +								<cstring>unnamed</cstring> +							</property> +							<widget class="TQLabel"> +								<property name="name"> +									<cstring>ddDeleteText</cstring> +								</property> +								<property name="text"> +									<string>Deletion method placeholder, never shown to user.</string> +								</property> +								<property name="alignment" stdset="0"> +									<string>WordBreak|AlignCenter</string> +								</property> +							</widget> +						</vbox> +					</widget> +				</hbox> +			</widget> +			<widget class="TDEListBox"> +				<property name="name"> +					<cstring>ddFileList</cstring> +				</property> +				<property name="selectionMode"> +					<enum>NoSelection</enum> +				</property> +				<property name="toolTip" stdset="0"> +					<string>List of files that are about to be deleted.</string> +				</property> +				<property name="whatsThis" stdset="0"> +					<string>This is the list of items that are about to be deleted.</string> +				</property> +			</widget> +			<widget class="TQLabel"> +				<property name="name"> +					<cstring>ddNumFiles</cstring> +				</property> +				<property name="text"> +					<string>Placeholder for number of files, not in GUI</string> +				</property> +				<property name="alignment" stdset="0"> +					<string>AlignVCenter|AlignRight</string> +				</property> +			</widget> +			<widget class="TQWidgetStack"> +				<property name="name"> +					<cstring>ddCheckBoxStack</cstring> +				</property> +				<widget class="TQWidget"> +					<property name="name"> +						<cstring>ddShouldDeletePage</cstring> +					</property> +					<attribute name="id"> +						<number>0</number> +					</attribute> +					<vbox> +						<property name="name"> +							<cstring>unnamed</cstring> +						</property> +						<property name="margin"> +							<number>0</number> +                                		</property> +						<widget class="TQCheckBox"> +							<property name="name"> +								<cstring>ddShouldDelete</cstring> +							</property> +							<property name="text"> +								<string>&Delete files instead of moving them to the trash</string> +							</property> +							<property name="toolTip" stdset="0"> +								<string>If checked, files will be permanently removed instead of being placed in the Trash Bin</string> +							</property> +							<property name="whatsThis" stdset="0"> +								<string><qt><p>If this box is checked, files will be <b>permanently removed</b> instead of being placed in the Trash Bin.</p> +									 +									<p><em>Use this option with caution</em>: most filesystems are unable to undelete deleted files reliably.</p></qt></string> +							</property> +						</widget> +					</vbox> +				</widget> +				<widget class="TQWidget"> +					<property name="name"> +						<cstring>ddDoNotShowAgainPage</cstring> +					</property> +					<attribute name="id"> +						<number>1</number> +					</attribute> +					<vbox> +						<property name="name"> +							<cstring>unnamed</cstring> +						</property> +						<property name="margin"> +							<number>0</number> +                                		</property> +						<widget class="TQCheckBox"> +							<property name="name"> +								<cstring>ddDoNotShowAgain</cstring> +							</property> +							<property name="text"> +								<string>Do not &ask again</string> +							</property> +							<property name="toolTip" stdset="0"> +								<string>If checked, this dialog will no longer be shown, and files will be directly moved to the Trash Bin</string> +							</property> +							<property name="whatsThis" stdset="0"> +								<string><qt><p>If this box is checked, this dialog will no longer be shown, and files will be directly moved to the Trash Bin</p></string> +							</property> +						</widget> +					</vbox> +				</widget> +			</widget> +		</vbox> +	</widget> +	<customwidgets> +	</customwidgets> +	<connections> +	</connections> +	<layoutdefaults spacing="6" margin="11"/> +	<includes> +		<include location="global" impldecl="in implementation">tdelistbox.h</include> +	</includes> +</UI> diff --git a/src/libs/dialogs/dprogressdlg.cpp b/src/libs/dialogs/dprogressdlg.cpp new file mode 100644 index 00000000..d4b0dc29 --- /dev/null +++ b/src/libs/dialogs/dprogressdlg.cpp @@ -0,0 +1,224 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2006-30-08 + * Description : a progress dialog for digiKam + *  + * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + *  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + *  + * ============================================================ */ + +// TQt includes. + +#include <tqlayout.h> +#include <tqwhatsthis.h> +#include <tqheader.h> +#include <tqlabel.h> +#include <tqimage.h> +#include <tqpushbutton.h> +#include <tqlistview.h> + +// KDE includes. + +#include <tdelocale.h> +#include <kprogress.h> +#include <tdeapplication.h> +#include <kdialogbase.h> +#include <kiconloader.h> +#include <kstandarddirs.h> + +// Local includes. + +#include "ddebug.h" +#include "dprogressdlg.h" +#include "dprogressdlg.moc" + +namespace Digikam +{ + +class DProgressDlgPriv +{ +public: + +    DProgressDlgPriv() +    { +        progress    = 0; +        actionsList = 0; +        logo        = 0; +        title       = 0; +        label       = 0; +        allowCancel = true; +        cancelled   = false; +    } + +    bool       allowCancel; +    bool       cancelled; + +    TQLabel    *logo; +    TQLabel    *title; +    TQLabel    *label; + +    TQListView *actionsList; + +    KProgress *progress; +}; + +DProgressDlg::DProgressDlg(TQWidget *parent, const TQString &caption) +            : KDialogBase(parent, 0, true, caption, Cancel) +{ +    d = new DProgressDlgPriv; + +    TQFrame *page      = makeMainWidget(); +    TQGridLayout* grid = new TQGridLayout(page, 1, 1, 0, spacingHint()); +    TQVBoxLayout *vlay = new TQVBoxLayout(); +    d->actionsList    = new TQListView(page); +    d->label          = new TQLabel(page); +    d->title          = new TQLabel(page); +    d->logo           = new TQLabel(page); +    d->progress       = new KProgress(page); +    vlay->addWidget(d->logo); +    vlay->addWidget(d->progress); +    vlay->addWidget(d->title); +    vlay->addStretch(); + +    TDEIconLoader* iconLoader = TDEApplication::kApplication()->iconLoader(); +    d->logo->setPixmap(iconLoader->loadIcon("digikam", TDEIcon::NoGroup, 128, TDEIcon::DefaultState, 0, true)); + +    d->actionsList->addColumn("Thumb");   // no i18n here: hiden column +    d->actionsList->addColumn("Status");  // no i18n here: hiden column +    d->actionsList->setSorting(-1); +    d->actionsList->setItemMargin(1); +    d->actionsList->setSelectionMode(TQListView::NoSelection); +    d->actionsList->header()->hide(); +    d->actionsList->setResizeMode(TQListView::LastColumn); + +    grid->addMultiCellLayout(vlay, 0, 1, 0, 0); +    grid->addMultiCellWidget(d->label, 0, 0, 1, 1); +    grid->addMultiCellWidget(d->actionsList, 1, 1, 1, 1); +    grid->setRowStretch(1, 10); +    grid->setColStretch(1, 10); +} + +DProgressDlg::~DProgressDlg() +{ +    delete d; +} + +void DProgressDlg::slotCancel() +{ +    d->cancelled = true; + +    if (d->allowCancel) +    { +        KDialogBase::slotCancel(); +    } +} + +void DProgressDlg::setButtonText(const TQString &text) +{ +    KDialogBase::setButtonText(Cancel, text); +} + +void DProgressDlg::addedAction(const TQPixmap& pix, const TQString &text) +{ +    TQImage img; +    TQListViewItem *item = new TQListViewItem(d->actionsList, +                          d->actionsList->lastItem(), TQString(), text); + +    if (pix.isNull()) +    { +        TQString dir = TDEGlobal::dirs()->findResourceDir("digikam_imagebroken", +                                                       "image-broken.png"); +        dir = dir + "/image-broken.png"; +        TQPixmap pixbi(dir); +        img = pixbi.convertToImage().scale(32, 32, TQImage::ScaleMin); +    } +    else +    { +        img = pix.convertToImage().scale(32, 32, TQImage::ScaleMin); +    } + +    TQPixmap pixmap(img); +    item->setPixmap(0, pixmap); +    d->actionsList->ensureItemVisible(item); +} + +void DProgressDlg::reset() +{ +    d->actionsList->clear(); +    d->progress->setValue(0); +} + +void DProgressDlg::setTotalSteps(int total) +{ +    d->progress->setTotalSteps(total); +} + +void DProgressDlg::setValue(int value) +{ +    d->progress->setValue(value); +} + +void DProgressDlg::advance(int value) +{ +    d->progress->advance(value); +} + +void DProgressDlg::setLabel(const TQString &text) +{ +    d->label->setText(text); +} + +void DProgressDlg::setTitle(const TQString &text) +{ +    d->title->setText(text); +} + +void DProgressDlg::showCancelButton(bool show) +{ +    showButtonCancel(show); +} + +void DProgressDlg::setAllowCancel(bool allowCancel) +{ +    d->allowCancel = allowCancel; +    showCancelButton(allowCancel); +} + +bool DProgressDlg::allowCancel() const +{ +    return d->allowCancel; +} + +bool DProgressDlg::wasCancelled() const +{ +    return d->cancelled; +} + +KProgress *DProgressDlg::progressBar() const +{ +    return d->progress; +} + +void DProgressDlg::setActionListVSBarVisible(bool visible) +{ +    if (!visible) +        d->actionsList->setVScrollBarMode(TQScrollView::AlwaysOff); +    else +        d->actionsList->setVScrollBarMode(TQScrollView::Auto); +} + +}  // NameSpace Digikam diff --git a/src/libs/dialogs/dprogressdlg.h b/src/libs/dialogs/dprogressdlg.h new file mode 100644 index 00000000..d75f509d --- /dev/null +++ b/src/libs/dialogs/dprogressdlg.h @@ -0,0 +1,79 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2006-30-08 + * Description : a progress dialog for digiKam + *  + * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + *  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + *  + * ============================================================ */ + +#ifndef DPROGRESSDLG_H +#define DPROGRESSDLG_H + +// KDE includes. + +#include <kdialogbase.h> + +// Local includes. + +#include "digikam_export.h" + +class KProgress; + +namespace Digikam +{ + +class DProgressDlgPriv; + +class DIGIKAM_EXPORT DProgressDlg : public KDialogBase +{ +TQ_OBJECT +   + + public: + +    DProgressDlg(TQWidget *parent=0, const TQString &caption=TQString()); +    ~DProgressDlg(); + +    void setButtonText(const TQString &text); +    void addedAction(const TQPixmap& pix, const TQString &text); +    void reset(); +    void setTotalSteps(int total); +    void setValue(int value); +    void advance(int value); +    void setLabel(const TQString &text); +    void setTitle(const TQString &text); +    void setActionListVSBarVisible(bool visible); +    void showCancelButton(bool show); +    void setAllowCancel(bool allowCancel); +    bool wasCancelled() const; +    bool allowCancel() const; + +    KProgress *progressBar() const; + + protected slots: + +    void slotCancel(); + + private: + +    DProgressDlgPriv* d; +}; + +}  // NameSpace Digikam + +#endif  // DPROGRESSDLG_H diff --git a/src/libs/dialogs/iccprofileinfodlg.cpp b/src/libs/dialogs/iccprofileinfodlg.cpp new file mode 100644 index 00000000..04f30c0c --- /dev/null +++ b/src/libs/dialogs/iccprofileinfodlg.cpp @@ -0,0 +1,60 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2006-02-16 + * Description : a dialog to display icc profile information. + *  + * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// KDE includes. + +#include <tdelocale.h> + +// Local includes. + +#include "ddebug.h" +#include "iccprofilewidget.h" +#include "iccprofileinfodlg.h" + +namespace Digikam +{ + +ICCProfileInfoDlg::ICCProfileInfoDlg(TQWidget* parent, const TQString& profilePath, +                                     const TQByteArray& profileData) +                 : KDialogBase(parent, 0, true, i18n("Color Profile Info"), +                               Help|Ok, Ok, true) +{ +    setHelp("iccprofile.anchor", "digikam"); +    setCaption(profilePath); +        +    ICCProfileWidget *profileWidget = new ICCProfileWidget(this, 0, 340, 256); +     +    if (profileData.isEmpty()) +        profileWidget->loadFromURL(KURL(profilePath)); +    else +        profileWidget->loadFromData(profilePath, profileData);  +                                      +    setMainWidget(profileWidget); +} + +ICCProfileInfoDlg::~ICCProfileInfoDlg() +{ +} + +}  // NameSpace Digikam + diff --git a/src/libs/dialogs/iccprofileinfodlg.h b/src/libs/dialogs/iccprofileinfodlg.h new file mode 100644 index 00000000..abcc1ed8 --- /dev/null +++ b/src/libs/dialogs/iccprofileinfodlg.h @@ -0,0 +1,58 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2006-02-16 + * Description : a dialog to display ICC profile information. + *  + * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + *  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + *  + * ============================================================ */ + +#ifndef ICCPROFILEINFODLG_H +#define ICCPROFILEINFODLG_H + +// TQt includes. + +#include <tqstring.h> + +// KDE includes. + +#include <kdialogbase.h> + +// Local includes. + +#include "digikam_export.h" + +class TQWidget; + +namespace Digikam +{ + +class ICCProfileInfoDlgPriv; + +class DIGIKAM_EXPORT ICCProfileInfoDlg : public KDialogBase +{ + +public: + +    ICCProfileInfoDlg(TQWidget *parent, const TQString& profilePath, const TQByteArray& profileData=TQByteArray()); +    ~ICCProfileInfoDlg(); + +}; + +}  // Namespace Digikam + +#endif /* ICCPROFILEINFODLG_H */ diff --git a/src/libs/dialogs/imagedialog.cpp b/src/libs/dialogs/imagedialog.cpp new file mode 100644 index 00000000..d052a2af --- /dev/null +++ b/src/libs/dialogs/imagedialog.cpp @@ -0,0 +1,366 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2008-03-13 + * Description : image files selector dialog. + *  + * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>  + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + *  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// TQt includes. + +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqguardedptr.h> +#include <tqtimer.h> + +// KDE includes. + +#include <tdeapplication.h> +#include <tdelocale.h> +#include <kstandarddirs.h> +#include <tdefiledialog.h> +#include <kimageio.h> +#include <kiconloader.h> + +// LibKDcraw includes. + +#include <libkdcraw/version.h> +#include <libkdcraw/kdcraw.h> + +#if KDCRAW_VERSION < 0x000106 +#include <libkdcraw/dcrawbinary.h> +#endif + +// Local includes. + +#include "ddebug.h" +#include "dmetadata.h" +#include "thumbnailsize.h" +#include "thumbnailjob.h" +#include "imagedialog.h" +#include "imagedialog.moc" + +namespace Digikam +{ + +class ImageDialogPreviewPrivate  +{ + +public: + +    ImageDialogPreviewPrivate() +    { +        imageLabel = 0; +        infoLabel  = 0; +        thumbJob   = 0; +        timer      = 0; +    } + +    TQTimer                    *timer; + +    TQLabel                    *imageLabel; +    TQLabel                    *infoLabel; + +    KURL                       currentURL; + +    DMetadata                  metaIface; + +    TQGuardedPtr<ThumbnailJob>  thumbJob; +}; + +ImageDialogPreview::ImageDialogPreview(TQWidget *parent) +                  : KPreviewWidgetBase(parent) +{ +    d = new ImageDialogPreviewPrivate; + +    TQVBoxLayout *vlay = new TQVBoxLayout(this); +    d->imageLabel     = new TQLabel(this); +    d->imageLabel->setAlignment(TQt::AlignHCenter | TQt::AlignVCenter); +    d->imageLabel->setSizePolicy(TQSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding)); + +    d->infoLabel = new TQLabel(this); + +    vlay->setMargin(0); +    vlay->setSpacing(KDialog::spacingHint()); +    vlay->addWidget(d->imageLabel); +    vlay->addWidget(d->infoLabel); + +    setSupportedMimeTypes(KImageIO::mimeTypes()); + +    d->timer = new TQTimer(this); + +    connect(d->timer, TQ_SIGNAL(timeout()),  +            this, TQ_SLOT(showPreview()) ); +} + +ImageDialogPreview::~ImageDialogPreview()  +{ +    if (!d->thumbJob.isNull()) +    { +        d->thumbJob->kill(); +        d->thumbJob = 0; +    } +    delete d; +} + +TQSize ImageDialogPreview::sizeHint() const +{ +    return TQSize(256, 256); +} + +void ImageDialogPreview::resizeEvent(TQResizeEvent *) +{ +    d->timer->start(100, true); +} + +void ImageDialogPreview::showPreview() +{ +    KURL url(d->currentURL); +    clearPreview(); +    showPreview(url); +} + +void ImageDialogPreview::showPreview(const KURL& url) +{ +    if (!url.isValid())  +    { +        clearPreview(); +        return; +    } + +    if (url != d->currentURL)  +    { +        clearPreview(); +        d->currentURL = url; + +        if (!d->thumbJob.isNull()) +        { +        d->thumbJob->kill(); +        d->thumbJob = 0; +        } + +        d->thumbJob = new ThumbnailJob(url, ThumbnailSize::Huge, true, true); + +        connect(d->thumbJob, TQ_SIGNAL(signalThumbnail(const KURL&, const TQPixmap&)), +                this, TQ_SLOT(slotGotThumbnail(const KURL&, const TQPixmap&))); + +        connect(d->thumbJob, TQ_SIGNAL(signalFailed(const KURL&)), +                this, TQ_SLOT(slotFailedThumbnail(const KURL&))); + +        d->metaIface.load(d->currentURL.path()); +        PhotoInfoContainer info = d->metaIface.getPhotographInformations(); +        if (!info.isEmpty()) +        { +            TQString identify; +            TQString make, model, dateTime, aperture, focalLength, exposureTime, sensitivity; +            TQString unavailable(i18n("<i>unavailable</i>")); +            TQString cellBeg("<tr><td><nobr><font size=-1>"); +            TQString cellMid("</font></nobr></td><td><nobr><font size=-1>"); +            TQString cellEnd("</font></nobr></td></tr>"); + +            if (info.make.isEmpty()) make = unavailable; +            else make = info.make; + +            if (info.model.isEmpty()) model = unavailable; +            else model = info.model; + +            if (!info.dateTime.isValid()) dateTime = unavailable; +            else dateTime = TDEGlobal::locale()->formatDateTime(info.dateTime, true, true); + +            if (info.aperture.isEmpty()) aperture = unavailable;  +            else aperture = info.aperture; + +            if (info.focalLength.isEmpty()) focalLength = unavailable;  +            else focalLength = info.focalLength; + +            if (info.exposureTime.isEmpty()) exposureTime = unavailable;  +            else exposureTime = info.exposureTime; + +            if (info.sensitivity.isEmpty()) sensitivity = unavailable;  +            else sensitivity = i18n("%1 ISO").arg(info.sensitivity); + +            identify = "<table cellspacing=0 cellpadding=0>"; +            identify += cellBeg + i18n("Make:")        + cellMid + make         + cellEnd; +            identify += cellBeg + i18n("Model:")       + cellMid + model        + cellEnd; +            identify += cellBeg + i18n("Created:")     + cellMid + dateTime     + cellEnd; +            identify += cellBeg + i18n("Aperture:")    + cellMid + aperture     + cellEnd; +            identify += cellBeg + i18n("Focal:")       + cellMid + focalLength  + cellEnd; +            identify += cellBeg + i18n("Exposure:")    + cellMid + exposureTime + cellEnd; +            identify += cellBeg + i18n("Sensitivity:") + cellMid + sensitivity  + cellEnd; +            identify += "</table>"; + +            d->infoLabel->setText(identify); +        } +        else +            d->infoLabel->clear(); +    } +} + +void ImageDialogPreview::slotGotThumbnail(const KURL& url, const TQPixmap& pix) +{ +    if (url == d->currentURL) +    { +        TQPixmap pixmap; +        TQSize s = d->imageLabel->contentsRect().size(); + +        if (s.width() < pix.width() || s.height() < pix.height()) +            pixmap = pix.convertToImage().smoothScale(s, TQImage::ScaleMin); +        else  +            pixmap = pix; + +        d->imageLabel->setPixmap(pixmap); +    } +} + +void ImageDialogPreview::slotFailedThumbnail(const KURL& /*url*/) +{ +    TDEIconLoader* iconLoader = TDEApplication::kApplication()->iconLoader(); +    d->imageLabel->setPixmap(iconLoader->loadIcon("image-x-generic", TDEIcon::NoGroup, 128, +                             TDEIcon::DefaultState, 0, true)); +} + +void ImageDialogPreview::clearPreview() +{ +    d->imageLabel->clear(); +    d->infoLabel->clear(); +    d->currentURL = KURL(); +} + +// ------------------------------------------------------------------------ + +class ImageDialogPrivate  +{ + +public: + +    ImageDialogPrivate() +    { +        singleSelect = false; +    } + +    bool       singleSelect; + +    TQString    fileformats; + +    KURL       url; +    KURL::List urls; +}; + +ImageDialog::ImageDialog(TQWidget* parent, const KURL &url, bool singleSelect, const TQString& caption) +{ +    d = new ImageDialogPrivate; +    d->singleSelect = singleSelect; + +    TQStringList patternList = TQStringList::split('\n', KImageIO::pattern(KImageIO::Reading)); + +    // All Images from list must been always the first entry given by KDE API +    TQString allPictures = patternList[0]; + +#if KDCRAW_VERSION < 0x000106 +    // Add other files format witch are missing to All Images" type mime provided by KDE and remplace current. +    if (KDcrawIface::DcrawBinary::instance()->versionIsRight()) +    { +        allPictures.insert(allPictures.find("|"), TQString(KDcrawIface::DcrawBinary::instance()->rawFiles()) + TQString(" *.JPE *.TIF")); +        patternList.remove(patternList[0]); +        patternList.prepend(allPictures); +        // Added RAW file formats supported by dcraw program like a type mime.  +        // Nota: we cannot use here "image/x-raw" type mime from KDE because it uncomplete  +        // or unavailable (see file #121242 in B.K.O). +        patternList.append(i18n("\n%1|Camera RAW files").arg(TQString(KDcrawIface::DcrawBinary::instance()->rawFiles()))); +    } +#else +    allPictures.insert(allPictures.find("|"), TQString(KDcrawIface::KDcraw::rawFiles()) + TQString(" *.JPE *.TIF")); +    patternList.remove(patternList[0]); +    patternList.prepend(allPictures); +    // Added RAW file formats supported by dcraw program like a type mime.  +    // Nota: we cannot use here "image/x-raw" type mime from KDE because it uncomplete  +    // or unavailable (see file #121242 in B.K.O). +    patternList.append(i18n("\n%1|Camera RAW files").arg(TQString(KDcrawIface::KDcraw::rawFiles()))); +#endif + +    d->fileformats = patternList.join("\n"); + +    DDebug() << "fileformats=" << d->fileformats << endl; + +    KFileDialog dlg(url.path(), d->fileformats, parent, "imageFileOpenDialog", false); +    ImageDialogPreview *preview = new ImageDialogPreview(&dlg); +    dlg.setPreviewWidget(preview); +    dlg.setOperationMode(KFileDialog::Opening); + +    if (d->singleSelect) +    { +        dlg.setMode(KFile::File); +        if (caption.isEmpty()) dlg.setCaption(i18n("Select an Image")); +        else dlg.setCaption(caption); +        dlg.exec(); +        d->url = dlg.selectedURL(); +    } +    else +    { +        dlg.setMode(KFile::Files); +        if (caption.isEmpty()) dlg.setCaption(i18n("Select Images")); +        else dlg.setCaption(caption); +        dlg.exec(); +        d->urls = dlg.selectedURLs(); +    } +} + +ImageDialog::~ImageDialog()  +{ +    delete d; +} + +bool ImageDialog::singleSelect() const  +{ +    return d->singleSelect; +} + +TQString ImageDialog::fileformats() const  +{ +    return d->fileformats; +} + +KURL ImageDialog::url() const +{ +    return d->url; +} + +KURL::List ImageDialog::urls() const +{ +    return d->urls; +} + +KURL::List ImageDialog::getImageURLs(TQWidget* parent, const KURL& url, const TQString& caption) +{ +    ImageDialog dlg(parent, url, false, caption); +    if (!dlg.urls().isEmpty()) +        return dlg.urls(); +    else +        return KURL::List(); +} + +KURL ImageDialog::getImageURL(TQWidget* parent, const KURL& url, const TQString& caption) +{ +    ImageDialog dlg(parent, url, true, caption); +    if (dlg.url() != KURL()) +        return dlg.url(); +    else +        return KURL(); +} + +} // namespace Digikam diff --git a/src/libs/dialogs/imagedialog.h b/src/libs/dialogs/imagedialog.h new file mode 100644 index 00000000..275765cd --- /dev/null +++ b/src/libs/dialogs/imagedialog.h @@ -0,0 +1,100 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2008-03-13 + * Description : image files selector dialog. + *  + * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>  + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + *  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#ifndef IMAGEDIALOG_H +#define IMAGEDIALOG_H + +// KDE includes. + +#include <kurl.h> +#include <kpreviewwidgetbase.h> + +// Local includes. + +#include "digikam_export.h" + +namespace Digikam +{ + +class ImageDialogPrivate; +class ImageDialogPreviewPrivate; + +class DIGIKAM_EXPORT ImageDialogPreview : public KPreviewWidgetBase +{ +    TQ_OBJECT +   + +public: + +    ImageDialogPreview(TQWidget *parent=0); +    ~ImageDialogPreview(); + +    TQSize sizeHint() const; + +public slots: + +    void showPreview(const KURL &url); + +private slots: + +    void showPreview(); +    void slotGotThumbnail(const KURL& url, const TQPixmap& pix); +    void slotFailedThumbnail(const KURL& url); +    void clearPreview(); + +private: + +    void resizeEvent(TQResizeEvent *e); + +private: + +    class ImageDialogPreviewPrivate *d; +}; + +// ------------------------------------------------------------------------ + +class DIGIKAM_EXPORT ImageDialog +{ + +public: + +    ImageDialog(TQWidget* parent, const KURL &url, bool singleSelect=false, const TQString& caption=TQString()); +    ~ImageDialog(); + +    KURL       url() const; +    KURL::List urls() const; + +    bool    singleSelect() const; +    TQString fileformats() const; + +    static KURL::List getImageURLs(TQWidget* parent, const KURL& url, const TQString& caption=TQString()); +    static KURL getImageURL(TQWidget* parent, const KURL& url, const TQString& caption=TQString()); + +private: + +    ImageDialogPrivate* d; +}; + +} // namespace Digikam + +#endif /* IMAGEDIALOG_H */ diff --git a/src/libs/dialogs/imagedlgbase.cpp b/src/libs/dialogs/imagedlgbase.cpp new file mode 100644 index 00000000..61666406 --- /dev/null +++ b/src/libs/dialogs/imagedlgbase.cpp @@ -0,0 +1,261 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2005-07-23 + * Description : simple plugins dialog without threadable + *               filter interface. The dialog layout is + *               designed to accept custom widgets in + *               preview and settings area. + * + * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// TQt includes. + +#include <tqgroupbox.h> +#include <tqlabel.h> +#include <tqwhatsthis.h> +#include <tqpushbutton.h> +#include <tqtimer.h> +#include <tqlayout.h> +#include <tqframe.h> +#include <tqtimer.h> +#include <tqsplitter.h> +#include <tqhbox.h> + +// KDE includes. + +#include <kcursor.h> +#include <tdelocale.h> +#include <tdeglobalsettings.h> +#include <tdeaboutdata.h> +#include <khelpmenu.h> +#include <kiconloader.h> +#include <tdeapplication.h> +#include <tdepopupmenu.h> +#include <kstandarddirs.h> +#include <tdeconfig.h> + +// Local includes. + +#include "ddebug.h" +#include "sidebar.h" +#include "dimginterface.h" +#include "imagedlgbase.h" +#include "imagedlgbase.moc" + +namespace Digikam +{ + +class ImageDlgBasePriv +{ +public: + +    ImageDlgBasePriv() +    { +        aboutData       = 0; +        timer           = 0; +        parent          = 0; +        mainLayout      = 0; +        hbox            = 0; +        settingsSideBar = 0; +        splitter        = 0; +    } + +    bool            tryAction; + +    TQGridLayout    *mainLayout; +     +    TQWidget        *parent; +     +    TQString         name; + +    TQTimer         *timer; + +    TQHBox          *hbox; + +    TQSplitter      *splitter; + +    TDEAboutData     *aboutData; + +    Sidebar        *settingsSideBar; +}; + +ImageDlgBase::ImageDlgBase(TQWidget* parent, TQString title, TQString name,  +                           bool loadFileSettings, bool tryAction, TQFrame* bannerFrame) +            : KDialogBase(Plain, 0, Help|Default|User1|User2|User3|Try|Ok|Cancel, Ok, +                          parent, 0, true, true, +                          TQString(), +                          i18n("&Save As..."), +                          i18n("&Load...")) +{ +    kapp->setOverrideCursor( KCursor::waitCursor() ); +    setCaption(DImgInterface::defaultInterface()->getImageFileName() + TQString(" - ") + title); +    showButton(User1, false); + +    d = new ImageDlgBasePriv; +    d->parent    = parent; +    d->name      = name; +    d->tryAction = tryAction; + +    setButtonWhatsThis ( Default, i18n("<p>Reset all filter parameters to their default values.") ); +    setButtonWhatsThis ( User3, i18n("<p>Load all filter parameters from settings text file.") ); +    setButtonWhatsThis ( User2, i18n("<p>Save all filter parameters to settings text file.") ); +    showButton(User2, loadFileSettings); +    showButton(User3, loadFileSettings); +    showButton(Try, tryAction); + +    resize(configDialogSize(name + TQString(" Tool Dialog"))); + +    // ------------------------------------------------------------- + +    d->mainLayout = new TQGridLayout( plainPage(), 2, 1); +    if (bannerFrame) +    { +        bannerFrame->reparent( plainPage(), TQPoint(0, 0) ); +        d->mainLayout->addMultiCellWidget(bannerFrame, 0, 0, 0, 1); +    } + +    // ------------------------------------------------------------- + +    d->hbox     = new TQHBox(plainPage()); +    d->splitter = new TQSplitter(d->hbox); +    d->splitter->setFrameStyle( TQFrame::NoFrame ); +    d->splitter->setFrameShadow( TQFrame::Plain ); +    d->splitter->setFrameShape( TQFrame::NoFrame );     +    d->splitter->setOpaqueResize(false); +     +    d->mainLayout->addMultiCellWidget(d->hbox, 1, 2, 0, 1); +    d->mainLayout->setColStretch(0, 10); +    d->mainLayout->setRowStretch(2, 10); + +    kapp->restoreOverrideCursor(); +} + +ImageDlgBase::~ImageDlgBase() +{ +    if (d->timer) +       delete d->timer; + +    if (d->aboutData) +       delete d->aboutData; + +    delete d->settingsSideBar; +    delete d; +} + +void ImageDlgBase::readSettings(void) +{ +    TDEConfig *config = kapp->config(); +    config->setGroup(d->name + TQString(" Tool Dialog")); +    if(config->hasKey("SplitterSizes")) +        d->splitter->setSizes(config->readIntListEntry("SplitterSizes")); + +    readUserSettings(); +} + +void ImageDlgBase::writeSettings() +{ +    TDEConfig *config = kapp->config(); +    config->setGroup(d->name + TQString(" Tool Dialog")); +    config->writeEntry("SplitterSizes", d->splitter->sizes()); +    config->sync(); +    saveDialogSize(d->name + TQString(" Tool Dialog")); +} + +void ImageDlgBase::closeEvent(TQCloseEvent *e) +{ +    writeSettings(); +    e->accept(); +} + +void ImageDlgBase::slotCancel() +{ +    writeSettings(); +    done(Cancel); +} + +void ImageDlgBase::slotOk() +{ +    writeSettings(); +    writeUserSettings(); +    finalRendering(); +} + +void ImageDlgBase::slotDefault() +{ +    resetValues(); +    slotEffect(); +} + +void ImageDlgBase::slotHelp() +{ +    // If setAboutData() is called by plugin, well DigikamImagePlugins help is launched,  +    // else digiKam help. In this case, setHelp() method must be used to set anchor and handbook name. + +    if (d->aboutData) +        TDEApplication::kApplication()->invokeHelp(d->name, "digikam"); +    else +        KDialogBase::slotHelp(); +} + +void ImageDlgBase::setAboutData(TDEAboutData *about) +{ +    d->aboutData = about; +    TQPushButton *helpButton = actionButton( Help ); +    KHelpMenu* helpMenu = new KHelpMenu(this, d->aboutData, false); +    helpMenu->menu()->removeItemAt(0); +    helpMenu->menu()->insertItem(i18n("digiKam Handbook"), this, TQ_SLOT(slotHelp()), 0, -1, 0); +    helpButton->setPopup( helpMenu->menu() ); +} + +void ImageDlgBase::setPreviewAreaWidget(TQWidget *w) +{ +    w->reparent( d->splitter, TQPoint(0, 0) ); +    TQSizePolicy rightSzPolicy(TQSizePolicy::Preferred, +                              TQSizePolicy::Expanding, +                              2, 1); +    w->setSizePolicy(rightSzPolicy); +} + +void ImageDlgBase::setUserAreaWidget(TQWidget *w) +{ +    TQString sbName(d->name + TQString(" Image Plugin Sidebar")); +    d->settingsSideBar = new Sidebar(d->hbox, sbName.ascii(), Sidebar::Right); +    d->settingsSideBar->setSplitter(d->splitter); +    d->settingsSideBar->appendTab(w, SmallIcon("configure"), i18n("Settings"));     +    d->settingsSideBar->loadViewState(); + +    readSettings();    +} + +void ImageDlgBase::slotTimer() +{ +    if (d->timer) +    { +       d->timer->stop(); +       delete d->timer; +    } + +    d->timer = new TQTimer( this ); +    connect( d->timer, TQ_SIGNAL(timeout()), +             this, TQ_SLOT(slotEffect()) ); +    d->timer->start(500, true); +} + +}  // NameSpace Digikam + diff --git a/src/libs/dialogs/imagedlgbase.h b/src/libs/dialogs/imagedlgbase.h new file mode 100644 index 00000000..97dc6a35 --- /dev/null +++ b/src/libs/dialogs/imagedlgbase.h @@ -0,0 +1,98 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2005-07-23 + * Description : simple plugins dialog without threadable  + *               filter interface. The dialog layout is  + *               designed to accept custom widgets in  + *               preview and settings area. + *  + * Copyright 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + *  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + *  + * ============================================================ */ + +#ifndef IMAGEDLGBASE_H +#define IMAGEDLGBASE_H + +// TQt includes + +#include <tqstring.h> + +// KDE includes. + +#include <kdialogbase.h> + +// Local includes. + +#include "digikam_export.h" + +class TQWidget; + +class TDEAboutData; + +namespace Digikam +{ + +class ImageDlgBasePriv; + +class DIGIKAM_EXPORT ImageDlgBase : public KDialogBase +{ +    TQ_OBJECT +   + +public: + +    ImageDlgBase(TQWidget *parent, TQString title, TQString name,  +                 bool loadFileSettings=true, bool tryAction=false, TQFrame* bannerFrame=0); +    ~ImageDlgBase(); + +    void setAboutData(TDEAboutData *about); +    void setPreviewAreaWidget(TQWidget *w); +    void setUserAreaWidget(TQWidget *w); + +protected slots: + +    virtual void slotDefault(); +    virtual void slotTimer();        +     +protected: +     +    void closeEvent(TQCloseEvent *e); +    virtual void finalRendering(){}; +    virtual void writeUserSettings(void){}; +    virtual void readUserSettings(void){ slotDefault(); }; +    virtual void resetValues(void){}; + +private slots: +     +    void slotHelp(); +    void slotCancel(); +    void slotOk();         +    virtual void slotEffect(){}; + +private: + +    void readSettings(void); +    void writeSettings(void); +  +private: + +    ImageDlgBasePriv* d; +}; + +}  // NameSpace Digikam + +#endif /* IMAGEDLGBASE */ diff --git a/src/libs/dialogs/imageguidedlg.cpp b/src/libs/dialogs/imageguidedlg.cpp new file mode 100644 index 00000000..9713a872 --- /dev/null +++ b/src/libs/dialogs/imageguidedlg.cpp @@ -0,0 +1,597 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2005-05-07 + * Description : A threaded filter plugin dialog with a preview + *               image guide widget and a settings user area + * + * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// TQt includes. + +#include <tqvgroupbox.h> +#include <tqlabel.h> +#include <tqpushbutton.h> +#include <tqwhatsthis.h> +#include <tqtooltip.h> +#include <tqlayout.h> +#include <tqframe.h> +#include <tqtimer.h> +#include <tqspinbox.h> +#include <tqsplitter.h> +#include <tqhbox.h> + +// KDE includes. + +#include <kcursor.h> +#include <tdelocale.h> +#include <tdeaboutdata.h> +#include <khelpmenu.h> +#include <kiconloader.h> +#include <tdeapplication.h> +#include <tdepopupmenu.h> +#include <kstandarddirs.h> +#include <tdeglobalsettings.h> +#include <kprogress.h> +#include <kcolorbutton.h> +#include <tdeconfig.h> +#include <kseparator.h> + +// Local includes. + +#include "ddebug.h" +#include "sidebar.h" +#include "dimgthreadedfilter.h" +#include "dimginterface.h" +#include "imageguidedlg.h" +#include "imageguidedlg.moc" + +namespace Digikam +{ + +class ImageGuideDlgPriv +{ +public: + +    enum RunningMode +    { +        NoneRendering=0, +        PreviewRendering, +        FinalRendering +    }; +     +    ImageGuideDlgPriv() +    { +        tryAction            = false; +        progress             = true; +        currentRenderingMode = NoneRendering; +        parent               = 0; +        settings             = 0; +        timer                = 0; +        aboutData            = 0; +        guideColorBt         = 0; +        progressBar          = 0; +        guideSize            = 0; +        mainLayout           = 0; +        settingsLayout       = 0; +        hbox                 = 0; +        settingsSideBar      = 0; +        splitter             = 0; +    } + +    bool          tryAction; +    bool          progress; +     +    int           currentRenderingMode; + +    TQWidget      *parent; +    TQWidget      *settings; +     +    TQTimer       *timer; +     +    TQString       name; + +    TQGridLayout  *mainLayout; +    TQGridLayout  *settingsLayout; +     +    TQSpinBox     *guideSize; + +    TQHBox        *hbox; + +    TQSplitter    *splitter; + +    KProgress    *progressBar; +         +    KColorButton *guideColorBt; + +    TDEAboutData   *aboutData; + +    Sidebar      *settingsSideBar; +}; + +ImageGuideDlg::ImageGuideDlg(TQWidget* parent, TQString title, TQString name, +                             bool loadFileSettings, bool progress, +                             bool guideVisible, int guideMode, TQFrame* bannerFrame, +                             bool prevModeOptions, bool useImageSelection, +                             bool tryAction) +             : KDialogBase(Plain, 0, +                           Help|Default|User1|User2|User3|Try|Ok|Cancel, Ok, +                           parent, 0, true, true, +                           i18n("&Abort"), +                           i18n("&Save As..."), +                           i18n("&Load...")) +{ +    kapp->setOverrideCursor( KCursor::waitCursor() ); +    setCaption(DImgInterface::defaultInterface()->getImageFileName() + TQString(" - ") + title); +     +    d = new ImageGuideDlgPriv; +    d->parent        = parent; +    d->name          = name; +    d->progress      = progress; +    d->tryAction     = tryAction; +    m_threadedFilter = 0; +    TQString whatsThis; + +    setButtonWhatsThis ( Default, i18n("<p>Reset all filter parameters to their default values.") ); +    setButtonWhatsThis ( User1, i18n("<p>Abort the current image rendering.") ); +    setButtonWhatsThis ( User3, i18n("<p>Load all filter parameters from settings text file.") ); +    setButtonWhatsThis ( User2, i18n("<p>Save all filter parameters to settings text file.") ); +    showButton(User2, loadFileSettings); +    showButton(User3, loadFileSettings); +    showButton(Try, tryAction); + +    resize(configDialogSize(name + TQString(" Tool Dialog"))); + +    // ------------------------------------------------------------- + +    d->mainLayout = new TQGridLayout( plainPage(), 2, 1); + +    if (bannerFrame) +    { +        bannerFrame->reparent( plainPage(), TQPoint(0, 0) ); +        d->mainLayout->addMultiCellWidget(bannerFrame, 0, 0, 0, 1); +    } + +    // ------------------------------------------------------------- + +    TQString desc; + +    if (guideVisible) +        desc = i18n("<p>This is the the image filter effect preview. " +                    "If you move the mouse cursor on this area, " +                    "a vertical and horizontal dashed line will be draw " +                    "to guide you in adjusting the filter settings. " +                    "Press the left mouse button to freeze the dashed " +                    "line's position."); +    else +        desc = i18n("<p>This is the image filter effect preview."); + +    d->hbox              = new TQHBox(plainPage()); +    d->splitter          = new TQSplitter(d->hbox); +    m_imagePreviewWidget = new ImageWidget(d->name, d->splitter, desc, prevModeOptions,  +                                           guideMode, guideVisible, useImageSelection); +     +    d->splitter->setFrameStyle( TQFrame::NoFrame ); +    d->splitter->setFrameShadow( TQFrame::Plain ); +    d->splitter->setFrameShape( TQFrame::NoFrame );     +    d->splitter->setOpaqueResize(false); +     +    TQSizePolicy rightSzPolicy(TQSizePolicy::Preferred, TQSizePolicy::Expanding, 2, 1); +    m_imagePreviewWidget->setSizePolicy(rightSzPolicy); + +    TQString sbName(d->name + TQString(" Image Plugin Sidebar")); +    d->settingsSideBar = new Sidebar(d->hbox, sbName.ascii(), Sidebar::Right); +    d->settingsSideBar->setSplitter(d->splitter); + +    d->mainLayout->addMultiCellWidget(d->hbox, 1, 2, 0, 1); +    d->mainLayout->setColStretch(0, 10); +    d->mainLayout->setRowStretch(2, 10); + +    // ------------------------------------------------------------- + +    d->settings          = new TQWidget(plainPage()); +    d->settingsLayout    = new TQGridLayout( d->settings, 1, 0); +    TQVBoxLayout *vLayout = new TQVBoxLayout( spacingHint() ); +     +    // ------------------------------------------------------------- + +    TQWidget *gboxGuideSettings = new TQWidget(d->settings); +    TQGridLayout* grid          = new TQGridLayout( gboxGuideSettings, 2, 2, marginHint(), spacingHint()); +    KSeparator *line           = new KSeparator(TQt::Horizontal, gboxGuideSettings); +    grid->addMultiCellWidget(line, 0, 0, 0, 2); + +    TQLabel *label5  = new TQLabel(i18n("Guide color:"), gboxGuideSettings); +    d->guideColorBt = new KColorButton( TQColor( TQt::red ), gboxGuideSettings ); +    TQWhatsThis::add( d->guideColorBt, i18n("<p>Set here the color used to draw guides dashed-lines.")); +    grid->addMultiCellWidget(label5, 1, 1, 0, 0); +    grid->addMultiCellWidget(d->guideColorBt, 1, 1, 2, 2); + +    TQLabel *label6 = new TQLabel(i18n("Guide width:"), gboxGuideSettings); +    d->guideSize   = new TQSpinBox( 1, 5, 1, gboxGuideSettings); +    TQWhatsThis::add( d->guideSize, i18n("<p>Set here the width in pixels used to draw guides dashed-lines.")); +    grid->addMultiCellWidget(label6, 2, 2, 0, 0); +    grid->addMultiCellWidget(d->guideSize, 2, 2, 2, 2); +    grid->setColStretch(1, 10); + +    if (guideVisible) gboxGuideSettings->show(); +    else gboxGuideSettings->hide(); + +    vLayout->addWidget(gboxGuideSettings); + +    TQHBox *hbox    = new TQHBox(d->settings); +    TQLabel *space1 = new TQLabel(hbox); +    space1->setFixedWidth(spacingHint());     +    d->progressBar = new KProgress(100, hbox); +    d->progressBar->setMaximumHeight( fontMetrics().height() ); +    TQWhatsThis::add(d->progressBar ,i18n("<p>This is the percentage of the task which has been completed up to this point.")); +    d->progressBar->setValue(0); +    setProgressVisible(false); +    TQLabel *space2 = new TQLabel(hbox); +    space2->setFixedWidth(spacingHint()); +     +    vLayout->addWidget(hbox); +    vLayout->addStretch(10); + +    d->settingsLayout->addMultiCellLayout(vLayout, 1, 1, 0, 0); + +    d->settingsSideBar->appendTab(d->settings, SmallIcon("configure"), i18n("Settings"));     +    d->settingsSideBar->loadViewState(); +     +    // Reading splitter sizes here prevent flicker effect in dialog. +    TDEConfig *config = kapp->config(); +    config->setGroup(d->name + TQString(" Tool Dialog")); +    if(config->hasKey("SplitterSizes")) +        d->splitter->setSizes(config->readIntListEntry("SplitterSizes")); + +    // ------------------------------------------------------------- + +    TQTimer::singleShot(0, this, TQ_SLOT(slotInit())); +    kapp->restoreOverrideCursor(); +} + +ImageGuideDlg::~ImageGuideDlg() +{ +    if (d->timer) +       delete d->timer; + +    if (m_threadedFilter) +       delete m_threadedFilter; + +    if (d->aboutData) +       delete d->aboutData; +     +    delete d->settingsSideBar;             +    delete d;             +} + +void ImageGuideDlg::readSettings(void) +{ +    TQColor defaultGuideColor(TQt::red); +    TDEConfig *config = kapp->config(); +    config->setGroup(d->name + TQString(" Tool Dialog")); +    d->guideColorBt->setColor(config->readColorEntry("Guide Color", &defaultGuideColor)); +    d->guideSize->setValue(config->readNumEntry("Guide Width", 1)); +    m_imagePreviewWidget->slotChangeGuideSize(d->guideSize->value()); +    m_imagePreviewWidget->slotChangeGuideColor(d->guideColorBt->color()); +} + +void ImageGuideDlg::writeSettings(void) +{ +    TDEConfig *config = kapp->config(); +    config->setGroup(d->name + TQString(" Tool Dialog")); +    config->writeEntry( "Guide Color", d->guideColorBt->color() ); +    config->writeEntry( "Guide Width", d->guideSize->value() ); +    config->writeEntry( "SplitterSizes", d->splitter->sizes() ); +    config->sync(); +    saveDialogSize(d->name + TQString(" Tool Dialog")); +} + +void ImageGuideDlg::slotInit() +{ +    readSettings(); +    // Reset values to defaults. +    TQTimer::singleShot(0, this, TQ_SLOT(readUserSettings())); + +    if (!d->tryAction) +    { +        connect(m_imagePreviewWidget, TQ_SIGNAL(signalResized()), +                this, TQ_SLOT(slotResized())); +    } + +    connect(d->guideColorBt, TQ_SIGNAL(changed(const TQColor &)), +            m_imagePreviewWidget, TQ_SLOT(slotChangeGuideColor(const TQColor &))); + +    connect(d->guideSize, TQ_SIGNAL(valueChanged(int)), +            m_imagePreviewWidget, TQ_SLOT(slotChangeGuideSize(int))); +} + +void ImageGuideDlg::setUserAreaWidget(TQWidget *w) +{ +    w->reparent( d->settings, TQPoint(0, 0) ); +    TQVBoxLayout *vLayout = new TQVBoxLayout( spacingHint() ); +    vLayout->addWidget(w); +    d->settingsLayout->addMultiCellLayout(vLayout, 0, 0, 0, 0); +} + +void ImageGuideDlg::setAboutData(TDEAboutData *about) +{ +    d->aboutData = about; +    TQPushButton *helpButton = actionButton( Help ); +    KHelpMenu* helpMenu = new KHelpMenu(this, d->aboutData, false); +    helpMenu->menu()->removeItemAt(0); +    helpMenu->menu()->insertItem(i18n("digiKam Handbook"), this, TQ_SLOT(slotHelp()), 0, -1, 0); +    helpButton->setPopup( helpMenu->menu() ); +} + +void ImageGuideDlg::setProgressVisible(bool v) +{ +    if (v) +        d->progressBar->show(); +    else +        d->progressBar->hide(); +} + +void ImageGuideDlg::abortPreview() +{ +    d->currentRenderingMode = ImageGuideDlgPriv::NoneRendering; +    d->progressBar->setValue(0); +    setProgressVisible(false); +    enableButton(Ok,      true); +    enableButton(User1,   false); +    enableButton(User2,   true); +    enableButton(User3,   true); +    enableButton(Try,     true); +    enableButton(Default, true); +    renderingFinished(); +} + +void ImageGuideDlg::slotTry() +{ +    slotEffect(); +} + +void ImageGuideDlg::slotResized(void) +{ +    if (d->currentRenderingMode == ImageGuideDlgPriv::FinalRendering) +    { +       m_imagePreviewWidget->update(); +       return; +    } +    else if (d->currentRenderingMode == ImageGuideDlgPriv::PreviewRendering) +    { +       if (m_threadedFilter) +          m_threadedFilter->stopComputation(); +    } + +    TQTimer::singleShot(0, this, TQ_SLOT(slotEffect())); +} + +void ImageGuideDlg::slotUser1() +{ +    if (d->currentRenderingMode != ImageGuideDlgPriv::NoneRendering) +        if (m_threadedFilter) +            m_threadedFilter->stopComputation(); +} + +void ImageGuideDlg::slotDefault() +{ +    resetValues(); +    slotEffect(); +} + +void ImageGuideDlg::slotCancel() +{ +    if (d->currentRenderingMode != ImageGuideDlgPriv::NoneRendering) +    { +       if (m_threadedFilter) +          m_threadedFilter->stopComputation(); + +       kapp->restoreOverrideCursor(); +    } +     +    writeSettings(); +    done(Cancel); +} + +void ImageGuideDlg::closeEvent(TQCloseEvent *e) +{ +    if (d->currentRenderingMode != ImageGuideDlgPriv::NoneRendering) +    { +       if (m_threadedFilter) +          m_threadedFilter->stopComputation(); + +       kapp->restoreOverrideCursor(); +    } + +    writeSettings(); +    e->accept(); +} + +void ImageGuideDlg::slotHelp() +{ +    // If setAboutData() is called by plugin, well DigikamImagePlugins help is lauched,  +    // else digiKam help. In this case, setHelp() method must be used to set anchor and handbook name. + +    if (d->aboutData) +        TDEApplication::kApplication()->invokeHelp(d->name, "digikam"); +    else +        KDialogBase::slotHelp(); +} + +void ImageGuideDlg::slotTimer() +{ +    if (d->timer) +    { +       d->timer->stop(); +       delete d->timer; +    } + +    d->timer = new TQTimer( this ); +    connect( d->timer, TQ_SIGNAL(timeout()), +             this, TQ_SLOT(slotEffect()) ); +    d->timer->start(500, true); +} + +void ImageGuideDlg::slotEffect() +{ +    // Computation already in process. +    if (d->currentRenderingMode != ImageGuideDlgPriv::NoneRendering) +        return; + +    d->currentRenderingMode = ImageGuideDlgPriv::PreviewRendering; +    DDebug() << "Preview " << d->name << " started..." << endl; + +    enableButton(Ok,      false); +    enableButton(User1,   true); +    enableButton(User2,   false); +    enableButton(User3,   false); +    enableButton(Default, false); +    enableButton(Try,     false); +    d->progressBar->setValue(0); +    if (d->progress) setProgressVisible(true); + +    if (m_threadedFilter) +    { +        delete m_threadedFilter; +        m_threadedFilter = 0; +    } + +    prepareEffect(); +} + +void ImageGuideDlg::slotOk() +{ +    d->currentRenderingMode = ImageGuideDlgPriv::FinalRendering; +    DDebug() << "Final " << d->name << " started..." << endl; +    writeSettings(); +    writeUserSettings(); + +    enableButton(Ok,      false); +    enableButton(User1,   false); +    enableButton(User2,   false); +    enableButton(User3,   false); +    enableButton(Default, false); +    enableButton(Try,     false); +    kapp->setOverrideCursor( KCursor::waitCursor() ); +    d->progressBar->setValue(0); + +    if (m_threadedFilter) +    { +        delete m_threadedFilter; +        m_threadedFilter = 0; +    } + +    prepareFinal(); +} + +void ImageGuideDlg::customEvent(TQCustomEvent *event) +{ +    if (!event) return; + +    DImgThreadedFilter::EventData *ed = (DImgThreadedFilter::EventData*) event->data(); + +    if (!ed) return; + +    if (ed->starting)           // Computation in progress ! +    { +        d->progressBar->setValue(ed->progress); +    } +    else +    { +        if (ed->success)        // Computation Completed ! +        { +            switch (d->currentRenderingMode) +            { +                case ImageGuideDlgPriv::PreviewRendering: +                { +                    DDebug() << "Preview " << d->name << " completed..." << endl; +                    putPreviewData(); +                    abortPreview(); +                    break; +                } + +                case ImageGuideDlgPriv::FinalRendering: +                { +                    DDebug() << "Final" << d->name << " completed..." << endl; +                    putFinalData(); +                    kapp->restoreOverrideCursor(); +                    accept(); +                    break; +                } +            } +        } +        else                   // Computation Failed ! +        { +            switch (d->currentRenderingMode) +            { +                case ImageGuideDlgPriv::PreviewRendering: +                { +                    DDebug() << "Preview " << d->name << " failed..." << endl; +                    // abortPreview() must be call here for set progress bar to 0 properly. +                    abortPreview(); +                    break; +                } + +                case ImageGuideDlgPriv::FinalRendering: +                    break; +            } +        } +    } + +    delete ed; +} + +// Backport KDialog::keyPressEvent() implementation from KDELibs to ignore Enter/Return Key events  +// to prevent any conflicts between dialog keys events and SpinBox keys events. + +void ImageGuideDlg::keyPressEvent(TQKeyEvent *e) +{ +    if ( e->state() == 0 ) +    { +        switch ( e->key() ) +        { +        case Key_Escape: +            e->accept(); +            reject(); +        break; +        case Key_Enter:             +        case Key_Return:      +            e->ignore();               +        break; +        default: +            e->ignore(); +            return; +        } +    } +    else +    { +        // accept the dialog when Ctrl-Return is pressed +        if ( e->state() == ControlButton && +            (e->key() == Key_Return || e->key() == Key_Enter) ) +        { +            e->accept(); +            accept(); +        } +        else +        { +            e->ignore(); +        } +    } +} + +}  // NameSpace Digikam diff --git a/src/libs/dialogs/imageguidedlg.h b/src/libs/dialogs/imageguidedlg.h new file mode 100644 index 00000000..e6841c43 --- /dev/null +++ b/src/libs/dialogs/imageguidedlg.h @@ -0,0 +1,123 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2005-05-07 + * Description : A threaded filter plugin dialog with a preview  + *               image guide widget and a settings user area + *  + * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + *  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + *  + * ============================================================ */ + +#ifndef IMAGEGUIDEDLG_H +#define IMAGEGUIDEDLG_H + +// TQt includes + +#include <tqstring.h> + +// KDE include. + +#include <kdialogbase.h> + +// Local includes. + +#include "imagewidget.h" +#include "imageguidewidget.h" +#include "digikam_export.h" + +class TQFrame; + +class TDEAboutData; + +namespace Digikam +{ + +class ImageGuideDlgPriv; +class DImgThreadedFilter; + +class DIGIKAM_EXPORT ImageGuideDlg : public KDialogBase +{ +    TQ_OBJECT +   + +public: + +    ImageGuideDlg(TQWidget* parent, TQString title, TQString name, +                  bool loadFileSettings=false, bool progress=true, +                  bool guideVisible=true, +                  int guideMode=ImageGuideWidget::HVGuideMode, +                  TQFrame* bannerFrame=0, +                  bool prevModeOptions=false, +                  bool useImageSelection=false, +                  bool tryAction=false); +    ~ImageGuideDlg(); + +    void setAboutData(TDEAboutData *about); +    void setUserAreaWidget(TQWidget *w); +    void setProgressVisible(bool v); +     +public: +         +    DImgThreadedFilter *m_threadedFilter; +     +    ImageWidget        *m_imagePreviewWidget; + +public slots:  + +    void slotTimer();        +    void slotEffect(); +    void slotOk(); +    void slotTry(); + +protected slots: +     +    virtual void slotCancel(); +    virtual void slotUser1(); +    virtual void slotDefault(); +    virtual void slotInit(); +    virtual void readUserSettings(void){ slotDefault(); }; + +private slots: +     +    void slotResized();            +    void slotHelp(); +     +protected: + +    void closeEvent(TQCloseEvent *e); +    void customEvent(TQCustomEvent *event); +    void abortPreview(void); +    void readSettings(void); +    void writeSettings(void); +    void keyPressEvent(TQKeyEvent *e); +             +    virtual void writeUserSettings(void){}; +    virtual void resetValues(void){}; +    virtual void prepareEffect(void){}; +    virtual void prepareFinal(void){}; +    virtual void putPreviewData(void){}; +    virtual void putFinalData(void){}; +    virtual void renderingFinished(void){}; + +private: +     +    ImageGuideDlgPriv* d; +}; + +}  // NameSpace Digikam + +#endif /* IMAGEGUIDEDLG_H */ diff --git a/src/libs/dialogs/rawcameradlg.cpp b/src/libs/dialogs/rawcameradlg.cpp new file mode 100644 index 00000000..298b47d4 --- /dev/null +++ b/src/libs/dialogs/rawcameradlg.cpp @@ -0,0 +1,178 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2008-04-07 + * Description : Raw camera list dialog + * + * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// TQt includes. + +#include <tqlayout.h> +#include <tqstringlist.h> +#include <tqstring.h> +#include <tqlabel.h> +#include <tqlistview.h> +#include <tqheader.h> + +// KDE includes. + +#include <tdelocale.h> +#include <kiconloader.h> +#include <tdeapplication.h> +#include <tdeaboutdata.h> + +// LibKDcraw includes. + +#include <libkdcraw/version.h> +#include <libkdcraw/kdcraw.h> + +#if KDCRAW_VERSION < 0x000106 +#include <libkdcraw/dcrawbinary.h> +#endif + +// Local includes. + +#include "searchtextbar.h" +#include "rawcameradlg.h" +#include "rawcameradlg.moc" + +namespace Digikam +{ + +class RawCameraDlgPriv +{ +public: + +    RawCameraDlgPriv() +    { +        listView  = 0; +        searchBar = 0; +    } + +    TQListView     *listView; + +    SearchTextBar *searchBar; +}; + +RawCameraDlg::RawCameraDlg(TQWidget *parent) +            : KDialogBase(parent, 0, true, TQString(), Help|Ok, Ok, true) +{ +    setHelp("digitalstillcamera.anchor", "digikam"); +    setCaption(i18n("List of supported RAW cameras")); + +    d = new RawCameraDlgPriv; + +    TQWidget *page     = makeMainWidget(); +    TQGridLayout* grid = new TQGridLayout(page, 2, 2, 0, spacingHint()); + +#if KDCRAW_VERSION < 0x000106 +    TQStringList list      = KDcrawIface::DcrawBinary::instance()->supportedCamera(); +    TQString     dcrawVer  = KDcrawIface::DcrawBinary::instance()->internalVersion(); +#else +    TQStringList list      = KDcrawIface::KDcraw::supportedCamera(); +    TQString     librawVer = KDcrawIface::KDcraw::librawVersion(); +#endif +    TQString     KDcrawVer = KDcrawIface::KDcraw::version(); + +    // -------------------------------------------------------- + +    TQLabel *logo            = new TQLabel(page); +    TDEIconLoader* iconLoader = TDEApplication::kApplication()->iconLoader(); + +    if (TDEApplication::kApplication()->aboutData()->appName() == TQString("digikam")) +        logo->setPixmap(iconLoader->loadIcon("digikam", TDEIcon::NoGroup, 96, TDEIcon::DefaultState, 0, true)); +    else +        logo->setPixmap(iconLoader->loadIcon("showfoto", TDEIcon::NoGroup, 96, TDEIcon::DefaultState, 0, true)); + +    // -------------------------------------------------------- + +    TQLabel *header = new TQLabel(page); +#if KDCRAW_VERSION < 0x000106 +    header->setText(i18n("<p>Using KDcraw library version %1" +                         "<p>Using Dcraw program version %2" +                         "<p>%3 models in the list") +                         .arg(KDcrawVer).arg(dcrawVer).arg(list.count())); +#else +    header->setText(i18n("<p>Using KDcraw library version %1" +                         "<p>Using LibRaw version %2" +                         "<p>%3 models in the list") +                         .arg(KDcrawVer).arg(librawVer).arg(list.count())); +#endif + +    // -------------------------------------------------------- + +    d->searchBar = new SearchTextBar(page, "RawCameraDlgSearchBar"); +    d->listView  = new TQListView(page); +    d->listView->addColumn("Camera Model");       // Header is hiden. No i18n here. +    d->listView->setSorting(1); +    d->listView->header()->hide(); +    d->listView->setResizeMode(TQListView::LastColumn); + +    for (TQStringList::Iterator it = list.begin() ; it != list.end() ; ++it) +        new TQListViewItem(d->listView, *it); + +    // -------------------------------------------------------- + + +    grid->addMultiCellWidget(logo,         0, 0, 0, 0); +    grid->addMultiCellWidget(header,       0, 0, 1, 2); +    grid->addMultiCellWidget(d->listView,  1, 1, 0, 2); +    grid->addMultiCellWidget(d->searchBar, 2, 2, 0, 2); +    grid->setColStretch(1, 10); +    grid->setRowStretch(1, 10); + +    // -------------------------------------------------------- + +    connect(d->searchBar, TQ_SIGNAL(signalTextChanged(const TQString&)), +            this, TQ_SLOT(slotSearchTextChanged(const TQString&))); + +    resize(500, 500); +} + +RawCameraDlg::~RawCameraDlg() +{ +    delete d; +} + +void RawCameraDlg::slotSearchTextChanged(const TQString& filter) +{ +    bool query     = false; +    TQString search = filter.lower(); + +    TQListViewItemIterator it(d->listView); + +    for ( ; it.current(); ++it ) +    { +        TQListViewItem *item  = it.current(); + +        if (item->text(0).lower().contains(search)) +        { +            query = true; +            item->setVisible(true); +        } +        else +        { +            item->setVisible(false); +        } +    } + +    d->searchBar->slotSearchResult(query); +} + +}  // NameSpace Digikam diff --git a/src/libs/dialogs/rawcameradlg.h b/src/libs/dialogs/rawcameradlg.h new file mode 100644 index 00000000..41d4a7de --- /dev/null +++ b/src/libs/dialogs/rawcameradlg.h @@ -0,0 +1,61 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2008-04-07 + * Description : Raw camera list dialog + * + * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#ifndef RAWCAMERADLG_H +#define RAWCAMERADLG_H + +// KDE includes. + +#include <kdialogbase.h> + +// Local includes. + +#include "digikam_export.h" + +namespace Digikam +{ + +class RawCameraDlgPriv; + +class DIGIKAM_EXPORT RawCameraDlg : public KDialogBase +{ +    TQ_OBJECT +   + +public: + +    RawCameraDlg(TQWidget* parent); +    ~RawCameraDlg(); + +private slots: + +    void slotSearchTextChanged(const TQString&); + +private: + +    RawCameraDlgPriv *d; +}; + +}  // NameSpace Digikam + +#endif  // RAWCAMERADLG_H | 
