TDE graphics utilities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

imageselectline.cpp 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /***************************************************************************
  2. imageselectline.cpp - select a background image.
  3. -------------------
  4. begin : Fri Dec 17 1999
  5. copyright : (C) 1999 by Klaas Freitag
  6. email : freitag@suse.de
  7. $Id$
  8. ***************************************************************************/
  9. /***************************************************************************
  10. * *
  11. * This file may be distributed and/or modified under the terms of the *
  12. * GNU General Public License version 2 as published by the Free Software *
  13. * Foundation and appearing in the file COPYING included in the *
  14. * packaging of this file. *
  15. *
  16. * As a special exception, permission is given to link this program *
  17. * with any version of the KADMOS ocr/icr engine of reRecognition GmbH, *
  18. * Kreuzlingen and distribute the resulting executable without *
  19. * including the source code for KADMOS in the source distribution. *
  20. *
  21. * As a special exception, permission is given to link this program *
  22. * with any edition of TQt, and distribute the resulting executable, *
  23. * without including the source code for TQt in the source distribution. *
  24. * *
  25. ***************************************************************************/
  26. #include <tqhbox.h>
  27. #include <tqvbox.h>
  28. #include <tqbutton.h>
  29. #include <tqpushbutton.h>
  30. #include <tqlabel.h>
  31. #include <kdebug.h>
  32. #include <klocale.h>
  33. #include <kurl.h>
  34. #include <kurlcombobox.h>
  35. #include <tdefiledialog.h>
  36. #include <kiconloader.h>
  37. #include "imageselectline.h"
  38. /* ############################################################################## */
  39. /*
  40. * This widget just combines a label, a combobox holding a path and a select button
  41. * together in a row. The button opens a file selector box to pick a file.
  42. */
  43. ImageSelectLine::ImageSelectLine( TQWidget *parent, const TQString& text )
  44. : TQHBox( parent )
  45. {
  46. setSpacing( 5 );
  47. (void) new TQLabel( text, this );
  48. m_urlCombo = new KURLComboBox( KURLComboBox::Files, this );
  49. m_buttFileSelect = new TQPushButton( this );
  50. m_buttFileSelect->setPixmap( SmallIcon( "fileopen" ) );
  51. m_urlCombo->setMaxItems(5);
  52. connect( m_urlCombo, TQT_SIGNAL( urlActivated( const KURL& )),
  53. this, TQT_SLOT( slUrlActivated( const KURL& )));
  54. connect( m_buttFileSelect, TQT_SIGNAL( clicked() ),
  55. this, TQT_SLOT( slSelectFile()));
  56. }
  57. void ImageSelectLine::slSelectFile()
  58. {
  59. KURL newUrl;
  60. newUrl = KFileDialog::getImageOpenURL();
  61. TQStringList l = m_urlCombo->urls();
  62. if( ! newUrl.isEmpty())
  63. {
  64. l.prepend( newUrl.url() );
  65. m_urlCombo->setURLs( l );
  66. m_currUrl = newUrl;
  67. }
  68. }
  69. void ImageSelectLine::slUrlActivated( const KURL& url )
  70. {
  71. kdDebug(28000) << "Activating url: " << url.url() << endl;
  72. m_currUrl = url;
  73. }
  74. KURL ImageSelectLine::selectedURL() const
  75. {
  76. return m_currUrl;
  77. }
  78. void ImageSelectLine::setURL( const KURL& url )
  79. {
  80. if( m_urlCombo ) m_urlCombo->setURL( url );
  81. m_currUrl = url;
  82. }
  83. void ImageSelectLine::setURLs( const TQStringList& list )
  84. {
  85. if( m_urlCombo ) m_urlCombo->setURLs( list );
  86. }
  87. #include "imageselectline.moc"