~tkluck/backintime/mountmonitor

« back to all changes in this revision

Viewing changes to kde4/app.py

  • Committer: Timo Kluck
  • Date: 2009-11-26 22:25:01 UTC
  • mfrom: (585.1.47 trunk)
  • Revision ID: tkluck@netbook-tjk-20091126222501-6cfwq1jfud2c0m3j
* added kde support
 * removed accidentally added ¨feature¨ of a per-folder on-mount action (added by copy pasting code)
 * merge with current version in trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#    Back In Time
2
 
#    Copyright (C) 2008-2009 Oprea Dan
 
2
#    Copyright (C) 2008-2009 Oprea Dan, Bart de Koning, Richard Bailey
3
3
#
4
4
#    This program is free software; you can redistribute it and/or modify
5
5
#    it under the terms of the GNU General Public License as published by
67
67
                self.main_toolbar = self.toolBar()
68
68
                self.main_toolbar.setFloatable( False )
69
69
 
 
70
                #profiles
 
71
                #self.main_toolbar.addWidget( QLabel( QString.fromUtf8( _('Profile:') ), self ) )
 
72
                self.first_update_all = True
 
73
                self.disable_profile_changed = False
 
74
                self.combo_profiles = KComboBox( self )
 
75
                self.combo_profiles_action = self.main_toolbar.addWidget( self.combo_profiles )
 
76
                #self.combo_profiles.setMinimumWidth( 250 )
 
77
 
70
78
                self.btn_take_snapshot = self.main_toolbar.addAction( KIcon( 'document-save' ), '' )
71
79
                self.btn_take_snapshot.setToolTip( QString.fromUtf8( _('Take snapshot') ) )
72
80
                QObject.connect( self.btn_take_snapshot, SIGNAL('triggered()'), self.on_btn_take_snapshot_clicked )
112
120
                self.btn_link = self.main_toolbar.addAction( KIcon( 'go-home' ), '' )
113
121
                self.btn_link.setToolTip( QString.fromUtf8( 'backintime.le-web.org' ) )
114
122
                QObject.connect( self.btn_link, SIGNAL('triggered()'), self.open_url )
115
 
 
 
123
                
116
124
                #main splitter
117
125
                self.main_splitter = QSplitter( self )
118
126
                self.main_splitter.setOrientation( Qt.Horizontal )
289
297
 
290
298
                if not cfg.is_configured():
291
299
                        return
 
300
        
 
301
                if self.config.get_update_other_folders() == True:
 
302
                        settingsdialog.SettingsDialog( self ).update_snapshot_location()
292
303
 
293
 
                if not cfg.can_backup():
 
304
                
 
305
                profile_id = cfg.get_current_profile()
 
306
                if not cfg.can_backup( profile_id ):
294
307
                        KMessageBox.error( self, QString.fromUtf8( _('Can\'t find snapshots folder.\nIf it is on a removable drive please plug it and then press OK') ) )
295
308
 
296
309
                QObject.connect( self.list_files_view_model.dirLister(), SIGNAL('completed()'), self.on_dir_lister_completed )
297
310
                QObject.connect( self.list_files_view_model.dirLister(), SIGNAL('canceled()'), self.on_dir_lister_completed )
298
311
 
299
312
                #populate lists
300
 
                self.update_time_line()
301
 
                self.update_places()
302
 
                self.update_files_view( 0 )
 
313
                self.update_profiles()
 
314
                QObject.connect( self.combo_profiles, SIGNAL('currentIndexChanged(int)'), self.on_profile_changed )
 
315
                #self.update_time_line()
 
316
                #self.update_places()
 
317
                #self.update_files_view( 0 )
303
318
 
304
319
                self.list_files_view.setFocus()
305
320
 
352
367
 
353
368
                event.accept()
354
369
 
 
370
        def update_profiles( self ):
 
371
                if self.disable_profile_changed:
 
372
                        return
 
373
 
 
374
                self.disable_profile_changed = True
 
375
 
 
376
                self.combo_profiles.clear()
 
377
 
 
378
                index = 0
 
379
                profiles = self.config.get_profiles_sorted_by_name()
 
380
 
 
381
                for profile_id in profiles:
 
382
                        if profile_id == self.config.get_current_profile():
 
383
                                index = self.combo_profiles.count()
 
384
                        self.combo_profiles.addItem( QString.fromUtf8( self.config.get_profile_name( profile_id ) ), QVariant( QString.fromUtf8( profile_id ) ) )
 
385
 
 
386
                self.combo_profiles.setCurrentIndex( index )
 
387
                self.combo_profiles_action.setVisible( len( profiles ) > 1 )
 
388
 
 
389
                self.update_profile()
 
390
 
 
391
                self.disable_profile_changed = False
 
392
 
 
393
        def update_profile( self ):
 
394
                self.update_time_line()
 
395
                self.update_places()
 
396
                self.update_files_view( 0 )
 
397
 
 
398
        def on_profile_changed( self, index ):
 
399
                if self.disable_profile_changed:
 
400
                        return
 
401
 
 
402
                profile_id = str( self.combo_profiles.itemData( index ).toString().toUtf8() )
 
403
                if len( profile_id ) <= 0:
 
404
                        return
 
405
                
 
406
                if profile_id != self.config.get_current_profile():
 
407
                        self.config.set_current_profile( profile_id )
 
408
                        self.update_profile()
 
409
 
355
410
        def get_default_startup_folder_and_file( self ):
356
411
                last_path = self.config.get_str_value( 'gnome.last_path', '' )
357
412
                if len(last_path) > 0 and os.path.isdir(last_path):
447
502
                elif not self.btn_take_snapshot.isEnabled():
448
503
                        self.btn_take_snapshot.setEnabled( True )
449
504
                        
450
 
                        snapshots_list = self.snapshots.get_snapshots_list()
 
505
                        snapshots_list = self.snapshots.get_snapshots_and_other_list()
451
506
 
452
507
                        if snapshots_list != self.snapshots_list:
453
508
                                self.snapshots_list = snapshots_list
567
622
                self.add_time_line( QString.fromUtf8( self.snapshots.get_snapshot_display_name( '/' ) ), '/' )
568
623
 
569
624
                if get_snapshots_list:
570
 
                        self.snapshots_list = self.snapshots.get_snapshots_list() 
 
625
                        self.snapshots_list = self.snapshots.get_snapshots_and_other_list() 
571
626
 
572
627
                groups = []
573
628
                now = datetime.date.today()
627
682
                                self.update_files_view( 2 )
628
683
 
629
684
        def on_btn_take_snapshot_clicked( self ):
630
 
                backintime.take_snapshot_now_async()
 
685
                backintime.take_snapshot_now_async( self.config )
631
686
                self.update_take_snapshot( True )
632
687
 
633
688
        def on_btn_update_snapshots_clicked( self ):
672
727
                self.update_time_line()
673
728
 
674
729
        def on_btn_settings_clicked( self ):
675
 
                snapshots_path = self.config.get_snapshots_path()
676
 
                include_folders = self.config.get_include_folders()
677
 
 
678
 
                settingsdialog.SettingsDialog( self ).exec_()
679
 
 
680
 
                update_files_view = ( include_folders != self.config.get_include_folders() )
681
 
 
682
 
                if snapshots_path == self.config.get_snapshots_path() and not update_files_view:
683
 
                   return
684
 
 
685
 
                if update_files_view:
686
 
                        self.update_places()
687
 
 
688
 
                if snapshots_path != self.config.get_snapshots_path():
689
 
                        self.update_time_line( True )
 
730
                if QDialog.Accepted == settingsdialog.SettingsDialog( self ).exec_():
 
731
                        self.update_profiles()
690
732
 
691
733
        def on_btn_about_clicked( self ):
692
734
                dlg = KAboutApplicationDialog( self.kaboutdata, self )
761
803
                if model_index is None:
762
804
                        return
763
805
 
764
 
                rel_path = str( self.list_files_view_sort_filter_proxy.data( model_index ).toString().toUtf8() )
 
806
                rel_path = str( self.list_files_view_sort_filter_proxy.data( model_index ).toString().toAscii() )
765
807
                if len( rel_path ) <= 0:
766
808
                        return
767
809
 
768
810
                rel_path = os.path.join( self.path, rel_path )
769
811
                full_path = self.snapshots.get_snapshot_path_to( self.snapshot_id, rel_path )
770
812
 
771
 
                if os.path.isdir( full_path ):
772
 
                        self.path = rel_path
773
 
                        self.update_files_view( 0 )
774
 
                else:
775
 
                        self.run = KRun( KUrl( full_path ), self, True )
 
813
                if os.path.exists( full_path ):
 
814
                        if os.path.isdir( full_path ):
 
815
                                self.path = rel_path
 
816
                                self.update_files_view( 0 )
 
817
                        else:
 
818
                                self.run = KRun( KUrl( full_path ), self, True )
776
819
 
777
820
        def files_view_get_name( self, item ):
778
821
                return str( item.text( 0 ).toUtf8() )
968
1011
 
969
1012
 
970
1013
def create_kapplication( cfg ):
971
 
        kaboutdata = KAboutData( 'backintime', '', ki18n( cfg.APP_NAME ), cfg.VERSION, ki18n( '' ), KAboutData.License_GPL_V2, ki18n( cfg.COPYRIGHT ), ki18n( '' ), 'http://backintime.le-web.org', 'dan@le-web.org' )
 
1014
        kaboutdata = KAboutData( 'backintime', '', ki18n( cfg.APP_NAME ), cfg.VERSION, ki18n( '' ), KAboutData.License_GPL_V2, ki18n( cfg.COPYRIGHT ), ki18n( '' ), 'http://backintime.le-web.org', 'bit-team@lists.launchpad.net' )
972
1015
        kaboutdata.setProgramIconName( 'document-save' )
973
1016
 
974
1017
        #extra_translations = _('about-translators')