diff --git a/src/AccessibleColorScheme.cpp b/src/AccessibleColorScheme.cpp new file mode 100644 index 00000000..f2f7319c --- /dev/null +++ b/src/AccessibleColorScheme.cpp @@ -0,0 +1,91 @@ +/* + This source file is part of Konsole, a terminal emulator. + + Copyright 2007-2008 by Robert Knight + + 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. + + 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. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. +*/ + +// Own +#include "AccessibleColorScheme.h" + +// Qt +#include + +// KDE +#include +#include + +using namespace Konsole; + +// Work In Progress - A color scheme for use on KDE setups for users +// with visual disabilities which means that they may have trouble +// reading text with the supplied color schemes. +// +// This color scheme uses only the 'safe' colors defined by the +// KColorScheme class. +// +// A complication this introduces is that each color provided by +// KColorScheme is defined as a 'background' or 'foreground' color. +// Only foreground colors are allowed to be used to render text and +// only background colors are allowed to be used for backgrounds. +// +// The ColorEntry and TerminalDisplay classes do not currently +// support this restriction. +// +// Requirements: +// - A color scheme which uses only colors from the KColorScheme class +// - Ability to restrict which colors the TerminalDisplay widget +// uses as foreground and background color +// - Make use of KGlobalSettings::allowDefaultBackgroundImages() as +// a hint to determine whether this accessible color scheme should +// be used by default. +// +// +// -- Robert Knight 21/07/2007 +// +AccessibleColorScheme::AccessibleColorScheme() + : ColorScheme() +{ + // basic attributes + setName("accessible"); + setDescription(i18n("Accessible Color Scheme")); + + // setup colors + const int ColorRoleCount = 8; + + const KColorScheme colorScheme(QPalette::Active); + + QBrush colors[ColorRoleCount] = { + colorScheme.foreground(colorScheme.NormalText), + colorScheme.background(colorScheme.NormalBackground), + + colorScheme.foreground(colorScheme.InactiveText), + colorScheme.foreground(colorScheme.ActiveText), + colorScheme.foreground(colorScheme.LinkText), + colorScheme.foreground(colorScheme.VisitedText), + colorScheme.foreground(colorScheme.NegativeText), + colorScheme.foreground(colorScheme.NeutralText) + }; + + for (int i = 0 ; i < TABLE_COLORS ; i++) { + ColorEntry entry; + entry.color = colors[ i % ColorRoleCount ].color(); + + setColorTableEntry(i , entry); + } +} + diff --git a/src/AccessibleColorScheme.h b/src/AccessibleColorScheme.h new file mode 100644 index 00000000..931c31a8 --- /dev/null +++ b/src/AccessibleColorScheme.h @@ -0,0 +1,47 @@ +/* + This source file is part of Konsole, a terminal emulator. + + Copyright 2007-2008 by Robert Knight + + 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. + + 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. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. +*/ + +#ifndef ACCESSIBLECOLORSCHEME_H +#define ACCESSIBLECOLORSCHEME_H + +// Konsole +#include "ColorScheme.h" + +namespace Konsole +{ + +/** + * A color scheme which uses colors from the standard KDE color palette. + * + * This is designed primarily for the benefit of users who are using specially + * designed colors. + * + * TODO Implement and make it the default on systems with specialized KDE + * color schemes. + */ +class AccessibleColorScheme : public ColorScheme +{ +public: + AccessibleColorScheme(); +}; +} + +#endif //ACCESSIBLECOLORSCHEME_H diff --git a/src/ColorScheme.cpp b/src/ColorScheme.cpp index b06defaa..1f27c940 100644 --- a/src/ColorScheme.cpp +++ b/src/ColorScheme.cpp @@ -23,11 +23,9 @@ #include "ColorScheme.h" // Qt -#include #include // KDE -#include #include #include #include @@ -424,62 +422,3 @@ QString ColorSchemeWallpaper::path() const return _path; } -// -// Work In Progress - A color scheme for use on KDE setups for users -// with visual disabilities which means that they may have trouble -// reading text with the supplied color schemes. -// -// This color scheme uses only the 'safe' colors defined by the -// KColorScheme class. -// -// A complication this introduces is that each color provided by -// KColorScheme is defined as a 'background' or 'foreground' color. -// Only foreground colors are allowed to be used to render text and -// only background colors are allowed to be used for backgrounds. -// -// The ColorEntry and TerminalDisplay classes do not currently -// support this restriction. -// -// Requirements: -// - A color scheme which uses only colors from the KColorScheme class -// - Ability to restrict which colors the TerminalDisplay widget -// uses as foreground and background color -// - Make use of KGlobalSettings::allowDefaultBackgroundImages() as -// a hint to determine whether this accessible color scheme should -// be used by default. -// -// -// -- Robert Knight 21/07/2007 -// -AccessibleColorScheme::AccessibleColorScheme() - : ColorScheme() -{ - // basic attributes - setName("accessible"); - setDescription(i18n("Accessible Color Scheme")); - - // setup colors - const int ColorRoleCount = 8; - - const KColorScheme colorScheme(QPalette::Active); - - QBrush colors[ColorRoleCount] = { - colorScheme.foreground(colorScheme.NormalText), - colorScheme.background(colorScheme.NormalBackground), - - colorScheme.foreground(colorScheme.InactiveText), - colorScheme.foreground(colorScheme.ActiveText), - colorScheme.foreground(colorScheme.LinkText), - colorScheme.foreground(colorScheme.VisitedText), - colorScheme.foreground(colorScheme.NegativeText), - colorScheme.foreground(colorScheme.NeutralText) - }; - - for (int i = 0 ; i < TABLE_COLORS ; i++) { - ColorEntry entry; - entry.color = colors[ i % ColorRoleCount ].color(); - - setColorTableEntry(i , entry); - } -} - diff --git a/src/ColorScheme.h b/src/ColorScheme.h index 107516f1..35c948e2 100644 --- a/src/ColorScheme.h +++ b/src/ColorScheme.h @@ -225,20 +225,6 @@ private: static const char* const translatedColorNames[TABLE_COLORS]; }; -/** - * A color scheme which uses colors from the standard KDE color palette. - * - * This is designed primarily for the benefit of users who are using specially - * designed colors. - * - * TODO Implement and make it the default on systems with specialized KDE - * color schemes. - */ -class AccessibleColorScheme : public ColorScheme -{ -public: - AccessibleColorScheme(); -}; } Q_DECLARE_METATYPE(const Konsole::ColorScheme*)