summaryrefslogtreecommitdiff
path: root/noncore/settings/appearance2/appearance.cpp
Unidiff
Diffstat (limited to 'noncore/settings/appearance2/appearance.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/appearance2/appearance.cpp210
1 files changed, 5 insertions, 205 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp
index 088171c..d649ed6 100644
--- a/noncore/settings/appearance2/appearance.cpp
+++ b/noncore/settings/appearance2/appearance.cpp
@@ -295,81 +295,2 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
295 295
296 QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 );
297
298 m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab );
299 m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" ));
300 lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 );
301 QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) );
302
303 QLabel *l = new QLabel ( tab );
304 l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" )));
305 lay-> addMultiCellWidget ( l, 1, 1, 0, 1 );
306 QWhatsThis::add( l, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) );
307
308 m_except = new QListView ( tab );
309 m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 );
310 m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 );
311 m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 );
312 m_except-> addColumn ( tr( "Binary file(s)" ));
313 m_except-> setColumnAlignment ( 0, AlignCenter );
314 m_except-> setColumnAlignment ( 1, AlignCenter );
315 m_except-> setColumnAlignment ( 2, AlignCenter );
316 m_except-> setAllColumnsShowFocus ( true );
317 m_except-> setMinimumHeight ( 30 );
318 m_except-> header ( )-> setClickEnabled ( false );
319 m_except-> header ( )-> setResizeEnabled ( false );
320 m_except-> header ( )-> setMovingEnabled ( false );
321 m_except-> setSorting ( -1 );
322 lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 );
323 QWhatsThis::add( m_except, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) );
324
325 connect ( m_except, SIGNAL( clicked(QListViewItem*,const QPoint&,int)), this, SLOT( clickedExcept(QListViewItem*,const QPoint&,int)));
326
327 QToolButton *tb = new QToolButton ( tab );
328 tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" ));
329 tb-> setFocusPolicy ( QWidget::StrongFocus );
330 lay-> addWidget ( tb, 2, 1 );
331 connect ( tb, SIGNAL( clicked()), this, SLOT( addExcept()));
332 QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) );
333
334 tb = new QToolButton ( tab );
335 tb-> setIconSet ( Resource::loadIconSet ( "editdelete" ));
336 tb-> setFocusPolicy ( QWidget::StrongFocus );
337 lay-> addWidget ( tb, 3, 1 );
338 connect ( tb, SIGNAL( clicked()), this, SLOT( delExcept()));
339 QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) );
340
341 tb = new QToolButton ( tab );
342 tb-> setIconSet ( Resource::loadIconSet ( "up" ));
343 tb-> setFocusPolicy ( QWidget::StrongFocus );
344 lay-> addWidget ( tb, 4, 1 );
345 connect ( tb, SIGNAL( clicked()), this, SLOT( upExcept()));
346 QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) );
347
348 tb = new QToolButton ( tab );
349 tb-> setIconSet ( Resource::loadIconSet ( "down" ));
350 tb-> setFocusPolicy ( QWidget::StrongFocus );
351 lay-> addWidget ( tb, 5, 1 );
352 connect ( tb, SIGNAL( clicked()), this, SLOT( downExcept()));
353 QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) );
354
355 lay-> setRowStretch ( 6, 10 );
356 lay-> setColStretch ( 0, 10 );
357
358 QStringList sl = cfg. readListEntry ( "NoStyle", ';' );
359 QListViewItem *lvit = 0;
360 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
361 {
362 int fl = ( *it ). left ( 1 ). toInt ( 0, 32 );
363
364 lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 );
365 }
366
367
368 vertLayout-> addSpacing ( 3 );
369 QFrame *f = new QFrame ( tab );
370 f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken );
371 vertLayout-> addWidget ( f );
372 vertLayout-> addSpacing ( 3 );
373
374
375 QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); 296 QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 );
@@ -457,2 +378,7 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
457 378
379
380 /*
381 * add a spacing
382 */
383 vertLayout->addItem( new QSpacerItem( 1, 1, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) );
458 return tab; 384 return tab;
@@ -569,19 +495,2 @@ void Appearance::accept ( )
569 495
570 m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated
571
572 QStringList sl;
573 QString exceptstr;
574 for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( ))
575 {
576 int fl = 0;
577 fl |= ( it-> noStyle ( ) ? 0x01 : 0 );
578 fl |= ( it-> noFont ( ) ? 0x02 : 0 );
579 fl |= ( it-> noDeco ( ) ? 0x04 : 0 );
580 exceptstr = QString::number ( fl, 32 );
581 exceptstr.append( it-> pattern ( ));
582 sl << exceptstr;
583 }
584 config. writeEntry ( "NoStyle", sl, ';' );
585 config. writeEntry ( "ForceStyle", m_force-> isChecked ( ));
586
587 config. write ( ); // need to flush the config info first 496 config. write ( ); // need to flush the config info first
@@ -783,110 +692 @@ void Appearance::deleteSchemeClicked()
783} }
784
785
786void Appearance::addExcept ( )
787{
788 ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true );
789 m_except-> ensureItemVisible ( it );
790 m_except-> setSelected ( it, true );
791}
792
793void Appearance::delExcept ( )
794{
795 if ( m_except-> selectedItem ( ))
796 {
797 m_except-> setFocus ( );
798 delete m_except-> selectedItem ( );
799 }
800}
801
802void Appearance::upExcept ( )
803{
804 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( );
805
806 if ( it && it-> itemAbove ( ))
807 it-> itemAbove ( )-> moveItem ( it );
808}
809
810void Appearance::downExcept ( )
811{
812 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( );
813
814 if ( it && it-> itemBelow ( ))
815 it-> moveItem ( it-> itemBelow ( ));
816}
817
818class ExEdit : public QLineEdit
819{
820public:
821 ExEdit ( ExceptListItem *item )
822 : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item )
823 {
824 setFrame ( false );
825
826 QRect r = it-> listView ( )-> itemRect ( it );
827
828 int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1;
829 int y = r. y ( );
830 int w = it-> listView ( )-> viewport ( )-> width ( ) - x;
831 int h = r. height ( ); // + 2;
832
833 setText ( it-> pattern ( ));
834 setGeometry ( x, y, w, h );
835
836 odebug << "ExEdit: [" << it->text(2).latin1() << "] at "
837 << x << "," << y << " " << w << "," << h << oendl;
838
839 m_out = true;
840
841 show ( );
842 setFocus ( );
843 selectAll ( );
844 end ( true );
845 }
846
847 virtual void focusOutEvent ( QFocusEvent * )
848 {
849 hide ( );
850 if ( m_out )
851 it-> setPattern ( text ( ));
852 delete this;
853 }
854
855 virtual void keyPressEvent ( QKeyEvent *e )
856 {
857 if ( e-> key ( ) == Key_Return )
858 it-> listView ( )-> setFocus ( );
859 else if ( e-> key ( ) == Key_Escape )
860 {
861 m_out = false;
862 it-> listView ( )-> setFocus ( );
863 }
864 else
865 QLineEdit::keyPressEvent ( e );
866 }
867
868private:
869 ExceptListItem *it;
870 bool m_out;
871};
872
873void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c )
874{
875 if ( !item || c < 0 || c > 3 )
876 return;
877
878 ExceptListItem *it = (ExceptListItem *) item;
879
880 if ( c == 0 )
881 it-> setNoStyle ( !it-> noStyle ( ));
882 else if ( c == 1 )
883 it-> setNoFont ( !it-> noFont ( ));
884 else if ( c == 2 )
885 it-> setNoDeco ( !it-> noDeco ( ));
886 else if ( c == 3 )
887 {
888 m_except-> ensureItemVisible ( it );
889 new ExEdit ( it );
890 }
891}
892