📄 kgcolors.cpp
字号:
/*************************************************************************** kgcolors.cpp - description ------------------- copyright : (C) 2004 + by Csaba Karai e-mail : krusader@users.sourceforge.net web site : http://krusader.sourceforge.net --------------------------------------------------------------------------- Description *************************************************************************** A db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD S o u r c e F i l e *************************************************************************** * * * 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 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#include "kgcolors.h"#include "../defaults.h"#include "../Panel/krcolorcache.h"#include <kmessagebox.h>#include <klocale.h>#include <kfiledialog.h>#include <kglobalsettings.h>#include <kstandarddirs.h>#include <qhbox.h>#include <qheader.h>#include <qtabwidget.h>KgColors::KgColors( bool first, QWidget* parent, const char* name ) : KonfiguratorPage( first, parent, name ), offset( 0 ){ QGridLayout *kgColorsLayout = new QGridLayout( parent ); kgColorsLayout->setSpacing( 6 ); // -------------------------- GENERAL GROUPBOX ---------------------------------- QGroupBox *generalGrp = createFrame( i18n( "General" ), parent, "kgColorsGeneralGrp" ); QGridLayout *generalGrid = createGridLayout( generalGrp->layout() ); generalGrid->setSpacing( 0 ); generalGrid->setMargin( 5 ); KONFIGURATOR_CHECKBOX_PARAM generalSettings[] = // cfg_class cfg_name default text restart tooltip {{"Colors","KDE Default", _KDEDefaultColors, i18n( "Use the default KDE colors" ), false, "<p><img src='toolbar|kcontrol'></p>" + i18n( "<p>Use KDE's global color configuration.</p><p><i>KDE Control Center -> Appearance & Themes -> Colors</i></p>") }, {"Colors","Enable Alternate Background", _AlternateBackground, i18n( "Use alternate background color" ), false, i18n( "<p>The <b>background color</b> and the <b>alternate background</b> color alternates line by line.</p><p>When you don't use the <i>KDE default colors</i>, you can configure the alternate colors in the <i>colors</i> box.</p>") }, {"Colors","Show Current Item Always", _ShowCurrentItemAlways, i18n( "Show current item even if not focused" ), false, i18n( "<p>Shows the last cursor position in the non active list panel.</p><p>This option is only available when you don't use the <i>KDE default colors</i>.</p>" ) }, {"Colors","Dim Inactive Colors", _DimInactiveColors, i18n( "Dim the colors of the inactive panel" ), false, i18n( "<p>The colors of the inactive panel are calculated by a dim color and a dim factor.</p>" ) }}; generals = createCheckBoxGroup( 0, 2, generalSettings, sizeof(generalSettings)/sizeof(generalSettings[0]), generalGrp ); generalGrid->addWidget( generals, 1, 0 ); generals->layout()->setSpacing( 5 ); connect( generals->find( "KDE Default" ), SIGNAL( stateChanged( int ) ), this, SLOT( slotDisable() ) ); connect( generals->find( "Enable Alternate Background" ), SIGNAL( stateChanged( int ) ), this, SLOT( generatePreview() ) ); connect( generals->find( "Show Current Item Always" ), SIGNAL( stateChanged( int ) ), this, SLOT( slotDisable() ) ); connect( generals->find( "Dim Inactive Colors" ), SIGNAL( stateChanged( int ) ), this, SLOT( slotDisable() ) ); kgColorsLayout->addMultiCellWidget( generalGrp, 0 ,0, 0, 2 ); QHBox *hbox = new QHBox( parent ); // -------------------------- COLORS GROUPBOX ---------------------------------- QGroupBox *colorsFrameGrp = createFrame( i18n( "Colors" ), hbox, "kgColorsColorsGrp" ); QGridLayout *colorsFrameGrid = createGridLayout( colorsFrameGrp->layout() ); colorsFrameGrid->setSpacing( 0 ); colorsFrameGrid->setMargin( 3 ); colorTabWidget = new QTabWidget( colorsFrameGrp, "colorTabWidget" ); connect( colorTabWidget, SIGNAL( currentChanged ( QWidget * ) ), this, SLOT( generatePreview() ) ); colorsGrp = new QWidget( colorTabWidget, "colorTab" ); colorTabWidget->insertTab( colorsGrp, i18n( "Active" ) ); colorsGrid = new QGridLayout( colorsGrp ); colorsGrid->setSpacing( 0 ); colorsGrid->setMargin( 2 ); ADDITIONAL_COLOR transparent = { i18n("Transparent"), Qt::white, "transparent" }; addColorSelector( "Foreground", i18n( "Foreground:" ), KGlobalSettings::textColor() ); addColorSelector( "Directory Foreground", i18n( "Directory foreground:" ), getColorSelector( "Foreground" )->getColor(), i18n( "Same as foreground" ) ); addColorSelector( "Executable Foreground", i18n( "Executable foreground:" ), getColorSelector( "Foreground" )->getColor(), i18n( "Same as foreground" ) ); addColorSelector( "Symlink Foreground", i18n( "Symbolic link foreground:" ), getColorSelector( "Foreground" )->getColor(), i18n( "Same as foreground" ) ); addColorSelector( "Invalid Symlink Foreground", i18n( "Invalid symlink foreground:" ), getColorSelector( "Foreground" )->getColor(), i18n( "Same as foreground" ) ); addColorSelector( "Background", i18n( "Background:" ), KGlobalSettings::baseColor() ); ADDITIONAL_COLOR sameAsBckgnd = { i18n("Same as background"), getColorSelector( "Background" )->getColor(), "Background" }; addColorSelector( "Alternate Background", i18n( "Alternate background:" ), KGlobalSettings::alternateBackgroundColor(),"", &sameAsBckgnd, 1 ); addColorSelector( "Marked Foreground", i18n( "Selected foreground:" ), KGlobalSettings::highlightedTextColor(), "", &transparent, 1 ); addColorSelector( "Marked Background", i18n( "Selected background:" ), KGlobalSettings::highlightColor(), "", &sameAsBckgnd, 1 ); ADDITIONAL_COLOR sameAsAltern = { i18n("Same as alt. background"), getColorSelector( "Alternate Background" )->getColor(), "Alternate Background" }; addColorSelector( "Alternate Marked Background",i18n( "Alternate selected background:" ), getColorSelector( "Marked Background" )->getColor(), i18n( "Same as selected background" ), &sameAsAltern, 1 ); addColorSelector( "Current Foreground", i18n( "Current foreground:" ), Qt::white, i18n( "Not used" ) ); ADDITIONAL_COLOR sameAsMarkedForegnd = { i18n("Same as selected foreground"), getColorSelector( "Marked Foreground" )->getColor(), "Marked Foreground" }; addColorSelector( "Marked Current Foreground", i18n( "Selected current foreground:" ), Qt::white, i18n( "Not used" ), &sameAsMarkedForegnd, 1); addColorSelector( "Current Background", i18n( "Current background:" ), Qt::white, i18n( "Not used" ), &sameAsBckgnd, 1 ); colorsGrid->addWidget(createSpacer(colorsGrp, ""), itemList.count() - offset, 1); connect( getColorSelector( "Foreground" ), SIGNAL( colorChanged() ), this, SLOT( slotForegroundChanged() ) ); connect( getColorSelector( "Background" ), SIGNAL( colorChanged() ), this, SLOT( slotBackgroundChanged() ) ); connect( getColorSelector( "Alternate Background" ), SIGNAL( colorChanged() ), this, SLOT( slotAltBackgroundChanged() ) ); connect( getColorSelector( "Marked Background" ), SIGNAL( colorChanged() ), this, SLOT( slotMarkedBackgroundChanged() ) ); inactiveColorStack = new QWidgetStack( colorTabWidget, "colorTab2" ); colorTabWidget->insertTab( inactiveColorStack, i18n( "Inactive" ) ); colorsGrp = normalInactiveWidget = new QWidget( inactiveColorStack, "colorTab2" ); colorsGrid = new QGridLayout( normalInactiveWidget ); colorsGrid->setSpacing( 0 ); colorsGrid->setMargin( 2 ); offset = endOfActiveColors = itemList.count(); addColorSelector( "Inactive Foreground", i18n( "Foreground:" ), getColorSelector( "Foreground" )->getColor(), i18n( "Same as active" ) ); ADDITIONAL_COLOR sameAsInactForegnd = { i18n("Same as foreground"), getColorSelector( "Inactive Foreground" )->getColor(), "Inactive Foreground" }; addColorSelector( "Inactive Directory Foreground", i18n( "Directory foreground:" ), getColorSelector( "Directory Foreground" )->getColor(), i18n( "Same as active" ), &sameAsInactForegnd, 1 ); addColorSelector( "Inactive Executable Foreground", i18n( "Executable foreground:" ), getColorSelector( "Executable Foreground" )->getColor(), i18n( "Same as active" ), &sameAsInactForegnd, 1 ); addColorSelector( "Inactive Symlink Foreground", i18n( "Symbolic link foreground:" ), getColorSelector( "Symlink Foreground" )->getColor(), i18n( "Same as active" ), &sameAsInactForegnd, 1 ); addColorSelector( "Inactive Invalid Symlink Foreground", i18n( "Invalid symlink foreground:" ), getColorSelector( "Invalid Symlink Foreground" )->getColor(), i18n( "Same as active" ), &sameAsInactForegnd, 1 ); addColorSelector( "Inactive Background", i18n( "Background:" ), getColorSelector( "Background" )->getColor(), i18n( "Same as active" ) ); ADDITIONAL_COLOR sameAsInactBckgnd = { i18n("Same as background"), getColorSelector( "Inactive Background" )->getColor(), "Inactive Background" }; addColorSelector( "Inactive Alternate Background", i18n( "Alternate background:" ), getColorSelector( "Alternate Background" )->getColor(), i18n( "Same as active" ), &sameAsInactBckgnd, 1 ); addColorSelector( "Inactive Marked Foreground", i18n( "Selected foreground:" ), getColorSelector( "Marked Foreground" )->getColor(), i18n( "Same as active" ), &transparent, 1 ); addColorSelector( "Inactive Marked Background", i18n( "Selected background:" ), getColorSelector( "Marked Background" )->getColor(), i18n( "Same as active" ), &sameAsInactBckgnd, 1 ); ADDITIONAL_COLOR sameAsInactAltern[] = {{ i18n("Same as alt. background"), getColorSelector( "Inactive Alternate Background" )->getColor(), "Inactive Alternate Background" }, { i18n("Same as selected background"), getColorSelector( "Inactive Marked Background" )->getColor(), "Inactive Marked Background" } }; addColorSelector( "Inactive Alternate Marked Background", i18n( "Alternate selected background:" ), getColorSelector( "Alternate Marked Background" )->getColor(), i18n( "Same as active" ), sameAsInactAltern, 2 ); addColorSelector( "Inactive Current Foreground", i18n( "Current foreground:" ), getColorSelector( "Current Foreground" )->getColor(), i18n( "Same as active" ) ); ADDITIONAL_COLOR sameAsInactMarkedForegnd = { i18n("Same as selected foreground"), getColorSelector( "Inactive Marked Foreground" )->getColor(), "Inactive Marked Foreground" }; addColorSelector( "Inactive Marked Current Foreground", i18n( "Selected current foreground:" ), getColorSelector( "Marked Current Foreground" )->getColor(), i18n( "Same as active" ), &sameAsInactMarkedForegnd, 1 ); addColorSelector( "Inactive Current Background", i18n( "Current background:" ), getColorSelector( "Current Background" )->getColor(), i18n( "Same as active" ), &sameAsInactBckgnd, 1 ); colorsGrid->addWidget(createSpacer(normalInactiveWidget, ""), itemList.count() - offset, 1); connect( getColorSelector( "Inactive Foreground" ), SIGNAL( colorChanged() ), this, SLOT( slotInactiveForegroundChanged() ) ); connect( getColorSelector( "Inactive Background" ), SIGNAL( colorChanged() ), this, SLOT( slotInactiveBackgroundChanged() ) ); connect( getColorSelector( "Inactive Alternate Background" ), SIGNAL( colorChanged() ), this, SLOT( slotInactiveAltBackgroundChanged() ) ); connect( getColorSelector( "Inactive Marked Background" ), SIGNAL( colorChanged() ), this, SLOT( slotInactiveMarkedBackgroundChanged() ) ); offset = endOfPanelColors = itemList.count(); inactiveColorStack->addWidget( normalInactiveWidget ); colorsGrp = dimmedInactiveWidget = new QWidget( inactiveColorStack, "colorTab2dimmed" ); colorsGrid = new QGridLayout( dimmedInactiveWidget ); colorsGrid->setSpacing( 0 ); colorsGrid->setMargin( 2 ); addColorSelector( "Dim Target Color", i18n( "Dim target color:" ), Qt::white); int index = itemList.count() - offset; labelList.append( addLabel( colorsGrid, index, 0, i18n("Dim factor:"), colorsGrp, QString( "ColorsLabel%1" ).arg( index ).ascii() ) ); dimFactor = createSpinBox("Colors", "Dim Factor", 100, 0, 100, colorsGrp); dimFactor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); connect( dimFactor, SIGNAL( valueChanged( int ) ), this, SLOT( generatePreview() ) ); colorsGrid->addWidget( dimFactor, index++, 1 ); colorsGrid->addWidget(createSpacer(dimmedInactiveWidget, ""), itemList.count() + 1 - offset, 1); inactiveColorStack->addWidget( dimmedInactiveWidget ); inactiveColorStack->raiseWidget( normalInactiveWidget ); colorsGrp = new QWidget( colorTabWidget, "colorTab3" ); colorTabWidget->insertTab( colorsGrp, i18n( "Synchronizer" ) ); colorsGrid = new QGridLayout( colorsGrp ); colorsGrid->setSpacing( 0 ); colorsGrid->setMargin( 2 ); ADDITIONAL_COLOR KDEDefaultBase = { i18n("KDE default"), KGlobalSettings::baseColor(), "KDE default" }; ADDITIONAL_COLOR KDEDefaultFore = { i18n("KDE default"), KGlobalSettings::textColor(), "KDE default" }; offset = endOfPanelColors = itemList.count(); addColorSelector( "Synchronizer Equals Foreground", i18n( "Equals foreground:" ), Qt::black, QString::null, &KDEDefaultFore, 1 ); addColorSelector( "Synchronizer Equals Background", i18n( "Equals background:" ), KGlobalSettings::baseColor(), QString::null, &KDEDefaultBase, 1 ); addColorSelector( "Synchronizer Differs Foreground", i18n( "Differing foreground:" ), Qt::red, QString::null, &KDEDefaultFore, 1 ); addColorSelector( "Synchronizer Differs Background", i18n( "Differing background:" ), KGlobalSettings::baseColor(), QString::null, &KDEDefaultBase, 1 ); addColorSelector( "Synchronizer LeftCopy Foreground", i18n( "Copy to left foreground:" ), Qt::blue, QString::null, &KDEDefaultFore, 1 ); addColorSelector( "Synchronizer LeftCopy Background", i18n( "Copy to left background:" ), KGlobalSettings::baseColor(), QString::null, &KDEDefaultBase, 1 ); addColorSelector( "Synchronizer RightCopy Foreground", i18n( "Copy to right foreground:" ), Qt::darkGreen, QString::null, &KDEDefaultFore, 1 ); addColorSelector( "Synchronizer RightCopy Background", i18n( "Copy to right background:" ), KGlobalSettings::baseColor(), QString::null, &KDEDefaultBase, 1 ); addColorSelector( "Synchronizer Delete Foreground", i18n( "Delete foreground:" ), Qt::white, QString::null, &KDEDefaultFore, 1 ); addColorSelector( "Synchronizer Delete Background", i18n( "Delete background:" ), Qt::red, QString::null, &KDEDefaultBase, 1 ); colorsGrid->addWidget(createSpacer(colorsGrp, ""), itemList.count() - offset, 1); colorsFrameGrid->addWidget( colorTabWidget, 0, 0 ); // -------------------------- PREVIEW GROUPBOX ---------------------------------- previewGrp = createFrame( i18n( "Preview" ), hbox, "kgColorsPreviewGrp" );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -