diff --git a/CMakeLists.txt b/CMakeLists.txt index 240625b76..79bcf824d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,250 +1,250 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR) find_package(ECM 1.8.0 REQUIRED NOMODULE) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include(SetKexiCMakePolicies NO_POLICY_SCOPE) include(SetKexiVersionInfo) project(Kexi VERSION ${PROJECT_VERSION}) include(ECMInstallIcons) include(ECMAddAppIcon) include(ECMSetupVersion) include(ECMAddTests) include(ECMMarkAsTest) include(ECMMarkNonGuiExecutable) include(ECMGenerateHeaders) include(ECMPoQmTools) include(KDEInstallDirs) include(KDECMakeSettings NO_POLICY_SCOPE) include(KDECompilerSettings NO_POLICY_SCOPE) include(KexiMacros) include(KexiAddIconsRccFile) ensure_out_of_source_build("Please refer to the build instruction https://community.kde.org/Kexi/Building") get_git_revision_and_branch() detect_release_build() ####################### ######################## ## Productset setting ## ######################## ####################### # For predefined productsets see the definitions in KexiProducts.cmake and # in the files in the folder cmake/productsets. # Finding out the products & features to build is done in 5 steps: # 1. have the user define the products/features wanted, by giving a productset # 2. estimate all additional required products/features # 3. estimate which of the products/features can be build by external deps # 4. find which products/features have been temporarily disabled due to problems # 5. estimate which of the products/features can be build by internal deps # get the special macros include(CalligraProductSetMacros) # get the definitions of products, features and product sets include(KexiProducts.cmake) set(PRODUCTSET_DEFAULT "ALL") if(NOT PRODUCTSET) set(PRODUCTSET ${PRODUCTSET_DEFAULT} CACHE STRING "Set of products/features to build" FORCE) endif() if (RELEASE_BUILD) set(KEXI_SHOULD_BUILD_STAGING FALSE) else () set(KEXI_SHOULD_BUILD_STAGING TRUE) endif () # finally choose products/features to build calligra_set_productset(${PRODUCTSET}) ########################## ########################### ## Look for Qt, KF5 ## ########################### ########################## set(REQUIRED_KF5_VERSION 5.16.0) find_package(KF5 ${REQUIRED_KF5_VERSION} REQUIRED COMPONENTS Archive Codecs Completion Config ConfigWidgets CoreAddons GuiAddons I18n IconThemes ItemViews KIO TextEditor TextWidgets WidgetsAddons XmlGui ) find_package(KF5 ${REQUIRED_KF5_VERSION} QUIET OPTIONAL_COMPONENTS Crash) macro_bool_to_01(KF5Crash_FOUND HAVE_KCRASH) macro_log_feature(${KF5Crash_FOUND} "KCrash" "KDE's Crash Handler" "https://api.kde.org/frameworks/kcrash/html" FALSE "" "Optionally used to provide crash reporting on Linux") set(REQUIRED_QT_VERSION 5.4.0) -find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Widgets Xml Network PrintSupport Test) +find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Widgets Xml Network PrintSupport Svg Test) find_package(Qt5 ${REQUIRED_QT_VERSION} COMPONENTS UiTools WebKit WebKitWidgets) # use sane compile flags add_definitions( -DQT_NO_CAST_TO_ASCII -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_NO_URL_CAST_FROM_STRING -DQT_STRICT_ITERATORS -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_QSTRINGBUILDER ) # only with COMPILING_TESTS definition will all the FOO_TEST_EXPORT macros do something # TODO: check if this can be moved to only those places which make use of it, # to reduce global compiler definitions that would trigger a recompile of # everything on a change (like adding/removing tests to/from the build) macro_bool_to_01(BUILD_TESTING COMPILING_TESTS) # overcome some platform incompatibilities if(WIN32) find_package(KDEWin REQUIRED) endif() # set custom Kexi plugin installdir set(KEXI_PLUGIN_INSTALL_DIR ${PLUGIN_INSTALL_DIR}/${KEXI_BASE_PATH}) # TEMPORARY: for initial Qt5/KF5 build porting phase deprecation warnings are only annoying noise # remove once code porting phase starts, perhaps first locally in product subdirs #if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC) # add_definitions(-Wno-deprecated -Wno-deprecated-declarations) #endif () ########################### ############################ ## Required dependencies ## ############################ ########################### set(KEXI_LIBS_MIN_VERSION 3.0.90) ## ## Test for KDb ## option(KEXI_DEBUG_GUI "Debugging GUI for Kexi (requires KDB_DEBUG_GUI to be set too)" OFF) if(KEXI_DEBUG_GUI) set(KDB_REQUIRED_COMPONENTS DEBUG_GUI) endif() find_package(KDb ${REQUIRED_KEXI_LIBS_VERSION} REQUIRED COMPONENTS ${KDB_REQUIRED_COMPONENTS}) macro_log_feature(KDb_FOUND "KDb" "A database connectivity and creation framework" "http://community.kde.org/KDb" FALSE "" "Required by Kexi for data handling") check_maximum_package_version(KDb ${MAXIMUM_KEXI_LIBS_VERSION}) ## ## Test for KReport ## find_package(KReport ${REQUIRED_KEXI_LIBS_VERSION} REQUIRED) if (KReport_FOUND) if(NOT KREPORT_SCRIPTING) message(FATAL_ERROR "Kexi requires KReport package with scripting support enabled (KREPORT_SCRIPTING)") endif() endif() check_maximum_package_version(KReport ${MAXIMUM_KEXI_LIBS_VERSION}) ## ## Test for KPropertyWidgets ## find_package(KPropertyWidgets ${KEXI_LIBS_MIN_VERSION} REQUIRED COMPONENTS KF) macro_log_feature(KPropertyWidgets_FOUND "KPropertyWidgets" "A property editing framework with editor widget" "http://community.kde.org/KProperty" FALSE "" "Required by Kexi") check_maximum_package_version(KPropertyWidgets ${MAXIMUM_KEXI_LIBS_VERSION}) include(CheckIfQtGuiCanBeExecuted) include(CheckGlobalBreezeIcons) ########################### ############################ ## Optional dependencies ## ############################ ########################### ## ## Test for marble ## set(MARBLE_MIN_VERSION "0.19.2") find_package(KexiMarble) if(NOT MARBLE_FOUND) set(MARBLE_INCLUDE_DIR "") else() set(HAVE_MARBLE TRUE) endif() macro_log_feature(MARBLE_FOUND "Marble" "KDE World Globe Widget library" "https://marble.kde.org/" FALSE "${MARBLE_MIN_VERSION}" "Required by Kexi form map widget") ## ## Test for Qt WebKitWidgets ## #TODO switch to Qt WebEngine macro_bool_to_01(Qt5WebKitWidgets_FOUND HAVE_QTWEBKITWIDGETS) macro_log_feature(Qt5WebKitWidgets_FOUND "Qt WebkitWidgets" "QWidgets module for Webkit, the HTML engine." "http://qt.io" FALSE "" "Required by Kexi web form widget") ################## ################### ## Helper macros ## ################### ################## include(MacroKexiAddBenchmark) include(MacroKexiAddTest) ############################################# #### Temporarily broken products #### ############################################# # If a product does not build due to some temporary brokeness disable it here, # by calling calligra_disable_product with the product id and the reason, # e.g.: # calligra_disable_product(APP_KEXI "isn't buildable at the moment") ############################################# #### Calculate buildable products #### ############################################# calligra_drop_unbuildable_products() ############################################# #### Setup product-depending vars #### ############################################# ################### #################### ## Subdirectories ## #################### ################### add_subdirectory(src) if(SHOULD_BUILD_DOC) find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS DocTools) add_subdirectory(doc) endif() # non-app directories are moved here because they can depend on SHOULD_BUILD_{appname} variables set above add_subdirectory(cmake) if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif() macro_display_feature_log() calligra_product_deps_report("product_deps") calligra_log_should_build() diff --git a/src/kexiutils/CMakeLists.txt b/src/kexiutils/CMakeLists.txt index 930926ebe..8176daa33 100644 --- a/src/kexiutils/CMakeLists.txt +++ b/src/kexiutils/CMakeLists.txt @@ -1,93 +1,96 @@ add_definitions(-DKDE_DEFAULT_DEBUG_AREA=44024) include_directories(completer) set(kexiutils_LIB_SRCS utils.cpp FontSettings_p.cpp InternalPropertyMap.cpp SmallToolButton.cpp KexiCommandLinkButton.cpp FlowLayout.cpp transliteration_table.cpp kmessagewidget.cpp KexiContextMessage.cpp KexiTitleLabel.cpp KexiLinkWidget.cpp KexiLinkButton.cpp KexiCloseButton.cpp KexiAssistantPage.cpp KexiAssistantWidget.cpp KexiAnimatedLayout.cpp KexiCategorizedView.cpp KexiTester.cpp KexiJsonTrader.cpp KexiPushButton.cpp KexiFadeWidgetEffect.cpp KexiPluginMetaData.cpp KexiStyle.cpp completer/KexiCompleter.cpp ) if (KEXI_MOBILE) else () if (KEXI_DEBUG_GUI) list(APPEND kexiutils_LIB_SRCS debuggui.cpp ) endif () endif () if(BUILD_TESTING) list(APPEND kexiutils_LIB_SRCS KexiTestHandler.cpp ) endif() kexi_add_library(kexiutils SHARED ${kexiutils_LIB_SRCS}) set(kexiutils_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ) target_include_directories(kexiutils PUBLIC "$" ) target_link_libraries(kexiutils PUBLIC KF5::KIOWidgets #for KRun... KF5::IconThemes KF5::WidgetsAddons KF5::ConfigWidgets # KStandardAction KColorScheme KF5::I18n KF5::ItemViews # KCategorizedView KCategoryDrawer KDb + + PRIVATE + Qt5::Svg ) #target_link_libraries(kexiutils LINK_INTERFACE_LIBRARIES KF5::KIOWidgets) if(BUILD_TESTING) target_link_libraries(kexiutils PRIVATE Qt5::Test ) endif() generate_export_header(kexiutils) install(TARGETS kexiutils ${INSTALL_TARGETS_DEFAULT_ARGS}) if(FALSE) # TODO: install when we move to independent place install( FILES tristate.h utils.h kexiutils_export.h kexiutils_global.h InternalPropertyMap.h SmallToolButton.h FlowLayout.h kmessagewidget.h KexiContextMessage.h KexiTitleLabel.h KexiAssistantPage.h KexiAssistantWidget.h KexiAnimatedLayout.h DESTINATION ${INCLUDE_INSTALL_DIR}/kexiutils COMPONENT Devel) endif() if(BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/src/kexiutils/KexiIcon.h b/src/kexiutils/KexiIcon.h index f56b7ef80..2244a4cf0 100644 --- a/src/kexiutils/KexiIcon.h +++ b/src/kexiutils/KexiIcon.h @@ -1,77 +1,78 @@ /* This file is part of the KDE project Copyright (C) 2012 Friedrich W. H. Kossebau Copyright (C) 2015-2016 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KEXIICON_H #define KEXIICON_H #include #include #include #include /** * Macros to support collecting the icons in use. * * After any change to this list of macros the file /CheckIcons.sh needs to be * updated accordingly, to ensure that the icon names of the affected macros are * still considered in the extraction. * * The naming pattern of the macros is like this: * * koIcon* returns a QIcon object * * koIconName* returns a QLatin1String (aligned with usual API where "iconName" property is of type QString) * * koIconNameCStr* returns a const char* */ //! Use these macros for icons without any issues - global icons (breeze) #define koIcon(name) (QIcon::fromTheme(QLatin1String(name))) +#define koDarkIcon(name, ...) (KexiStyle::darkIcon(QLatin1String(name), ##__VA_ARGS__)) #define koIconName(name) (QLatin1String(name)) #define koIconNameCStr(name) (name) #define koSmallIcon(name) (QIcon::fromTheme(QLatin1String(name)).pixmap(IconSize(KIconLoader::Small))) #define koDesktopIcon(name) (QIcon::fromTheme(QLatin1String(name)).pixmap(IconSize(KIconLoader::Desktop))) #define koSmallIconCStr(name) (QIcon::fromTheme(name).pixmap(IconSize(KIconLoader::Small))) #define koDesktopIconCStr(name) (QIcon::fromTheme(name).pixmap(IconSize(KIconLoader::Desktop))) //! Use these macros if there is a proper icon missing #define koIconNeeded(comment, neededName) (QIcon::fromTheme(QLatin1String(neededName))) #define koIconNeededWithSubs(comment, neededName, substituteName) (QIcon::fromTheme(QLatin1String(substituteName))) #define koIconNameNeeded(comment, neededName) (QLatin1String(neededName)) #define koIconNameNeededWithSubs(comment, neededName, substituteName) (QLatin1String(substituteName)) #define koIconNameCStrNeeded(comment, neededName) (neededName) #define koIconNameCStrNeededWithSubs(comment, neededName, substituteName) (substituteName) //! Use these macros if the UI is okay without any icon, but would be better with one. #define koIconWanted(comment, wantedName) (QIcon()) #define koIconNameWanted(comment, wantedName) (QString()) //! Use these macros for icons without any issues - Kexi icons #define KexiIcon(name) koIcon(name) #define KexiIconName(name) koIconName(name) #define KexiIconNameCStr(name) koIconNameCStr(name) #define KexiSmallIcon(name) koSmallIcon(name) #define KexiDesktopIcon(name) koDesktopIcon(name) //! Use this function to load an icon that fits the current color theme KEXIUTILS_EXPORT QIcon themedIcon(const QString &name); //! Use this function to find an icon name that fits the current color theme KEXIUTILS_EXPORT QString themedIconName(const QString &name); #endif diff --git a/src/kexiutils/KexiStyle.cpp b/src/kexiutils/KexiStyle.cpp index f0fef7372..7aefb38dc 100644 --- a/src/kexiutils/KexiStyle.cpp +++ b/src/kexiutils/KexiStyle.cpp @@ -1,119 +1,234 @@ /* This file is part of the KDE project Copyright (C) 2016 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KexiStyle.h" #include "utils.h" + #include #include #include #include +#include +#include +#include namespace KexiStyle { KEXIUTILS_EXPORT void setupFrame(QFrame *frame) { if (frame) { frame->setFrameStyle(QFrame::NoFrame); } } KEXIUTILS_EXPORT void setupModeSelector(QFrame *selector) { KexiStyle::setupFrame(selector); selector->setFont(KexiUtils::smallestReadableFont()); - selector->setPalette(KexiStyle::alternativePalette(selector->palette())); + QPalette p(selector->palette()); + p.setColor(QPalette::Window, KexiUtils::shadeBlack()); + p.setColor(QPalette::Base, KexiUtils::shadeBlack()); + p.setColor(QPalette::Button, KexiUtils::shadeBlack()); + p.setColor(QPalette::AlternateBase, KexiUtils::shadeBlackLighter()); + p.setColor(QPalette::WindowText, KexiUtils::cardboardGrey()); + p.setColor(QPalette::ButtonText, KexiUtils::cardboardGrey()); + p.setColor(QPalette::Text, KexiUtils::cardboardGrey()); + p.setColor(QPalette::Highlight, KexiUtils::cardboardGrey()); + p.setColor(QPalette::Active, QPalette::Highlight, KexiUtils::plasmaBlue()); // unused anyway because mode selector has no focus + p.setColor(QPalette::HighlightedText, KexiUtils::charcoalGrey()); + selector->setPalette(p); } KEXIUTILS_EXPORT void overpaintModeSelector(QWidget *widget, QPainter *painter, const QRect &selectedRect) { // draw gradient painter->save(); int w = widget->fontMetrics().height() * 3 / 2; painter->translate(widget->width() - w, 0); QLinearGradient grad(0, 0, w, 0); QColor c(widget->palette().base().color()); c.setAlpha(0); grad.setColorAt(0, c); c.setAlpha(15); grad.setColorAt(0.5, c); grad.setColorAt(1.0, QColor(0, 0, 0, 50)); painter->fillRect(0, 0, w, widget->height(), QBrush(grad)); painter->restore(); // draw: /| // \| if (!selectedRect.isNull()) { painter->save(); w = selectedRect.height() / 10; if (w % 2 == 0) { ++w; } painter->translate(selectedRect.x() + selectedRect.width() - w, selectedRect.y() + (selectedRect.height() - w * 2) / 2 - 0.5); QPolygon polygon; polygon << QPoint(w, 0) << QPoint(w, w * 2) << QPoint(0, w); painter->setPen(QPen(Qt::NoPen)); painter->setBrush(KexiUtils::charcoalGrey()); painter->drawPolygon(polygon); painter->restore(); } } KEXIUTILS_EXPORT void overpaintModeSelectorItem(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) { Q_UNUSED(painter) Q_UNUSED(option) Q_UNUSED(index) } KEXIUTILS_EXPORT QPalette alternativePalette(const QPalette &palette) { QPalette p(palette); p.setColor(QPalette::Window, KexiUtils::charcoalGrey()); p.setColor(QPalette::Base, KexiUtils::shadeBlack()); p.setColor(QPalette::Button, KexiUtils::shadeBlack()); p.setColor(QPalette::AlternateBase, KexiUtils::shadeBlackLighter()); p.setColor(QPalette::WindowText, KexiUtils::paperWhite()); p.setColor(QPalette::ButtonText, KexiUtils::paperWhite()); p.setColor(QPalette::Text, KexiUtils::paperWhite()); + p.setColor(QPalette::Highlight, KexiUtils::cardboardGrey()); + p.setColor(QPalette::Active, QPalette::Highlight, KexiUtils::plasmaBlue()); + p.setColor(QPalette::HighlightedText, KexiUtils::charcoalGrey()); + p.setColor(QPalette::Active, QPalette::HighlightedText, KexiUtils::cardboardGrey()); return p; } KEXIUTILS_EXPORT QPalette sidebarsPalette(const QPalette &palette) { return alternativePalette(palette); } KEXIUTILS_EXPORT void setSidebarsPalette(QWidget *widget) { widget->setPalette(sidebarsPalette(widget->palette())); widget->setAutoFillBackground(true); } KEXIUTILS_EXPORT QFont titleFont(const QFont &font) { QFont newFont(font); newFont.setCapitalization(QFont::AllUppercase); return newFont; } +static const QString g_contexts[] = { + QLatin1String("actions"), // Any + QLatin1String("actions"), + QLatin1String("apps"), + QLatin1String("devices"), + QLatin1String("filesystems"), + QLatin1String("mimetypes"), + QLatin1String("animations"), + QLatin1String("categories"), + QLatin1String("emblems"), + QLatin1String("emotes"), + QLatin1String("intl"), + QLatin1String("places"), + QLatin1String("status") +}; + +KEXIUTILS_EXPORT QIcon darkIcon(const QString &iconName, KIconLoader::Context iconContext) +{ + Q_ASSERT(iconContext < (sizeof(g_contexts) / sizeof(g_contexts[0]))); + static const QIcon::Mode modes[] = { QIcon::Normal }; //can be supported too: , QIcon::Selected }; + const QString prefix(QLatin1String(":/icons/breeze/") + + g_contexts[iconContext] + QLatin1Char('/')); + const QString suffixes[] = { + iconName + QLatin1String("@dark.svg"), + iconName + QLatin1String(".svg") }; + static const QString sizesStr[] = { + QString::fromLatin1("32/"), // important: opposite direction + QString::fromLatin1("22/"), + QString::fromLatin1("16/") }; + static const QSize sizes[] = { QSize(32, 32), QSize(22, 22), QSize(16, 16) }; // important: opposite direction + QIcon icon; + for (int mode = 0; mode < int(sizeof(modes) / sizeof(modes[0])); ++mode) { + for (int size = 0; size < int(sizeof(sizes) / sizeof(sizes[0])); ++size) { + //qDebug() << prefix + sizesStr[size] + suffixes[mode] << sizes[size] << modes[mode]; + icon.addFile(prefix + sizesStr[size] + suffixes[mode], sizes[size], modes[mode], QIcon::Off); + icon.addFile(prefix + sizesStr[size] + suffixes[mode], sizes[size], modes[mode], QIcon::On); + } + } + return icon; +} + +class IconEngine : public QIconEngine +{ +public: + IconEngine(const KexiStyledIconParameters ¶meters) + : m_parameters(parameters) + { + } + inline QIconEngine *clone() const Q_DECL_OVERRIDE { + return new IconEngine(*this); + } + + //! @todo add caching? + QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE { + Q_UNUSED(state) + QFile f(QLatin1String(":/icons/breeze/") + g_contexts[m_parameters.context] + QChar('/') + QString::number(size.width()) + + QChar('/') + m_parameters.name + ".svg"); + if (!f.open(QIODevice::ReadOnly)) { + return QPixmap(); + } + QByteArray svg(f.readAll()); + if (mode == QIcon::Selected && m_parameters.selectedColor.isValid()) { + svg.replace(KexiUtils::iconGrey().name().toLatin1(), + m_parameters.selectedColor.name().toLatin1()); + } else if (m_parameters.color.isValid()) { + svg.replace(KexiUtils::iconGrey().name().toLatin1(), + m_parameters.color.name().toLatin1()); + } + QSvgRenderer renderer(svg); + QPixmap pm(size); + pm.fill(Qt::transparent); + QPainter p(&pm); + renderer.render(&p, pm.rect()); + return pm; + } + + //! Nothing to paint extra here + void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE { + Q_UNUSED(painter) + Q_UNUSED(rect) + Q_UNUSED(mode) + Q_UNUSED(state) + } + +private: + //! Needed for clone() + IconEngine(const IconEngine &other) : m_parameters(other.m_parameters) {} + + const KexiStyledIconParameters m_parameters; +}; + +KEXIUTILS_EXPORT QIcon icon(const KexiStyledIconParameters ¶meters) +{ + return QIcon(new IconEngine(parameters)); +} + } diff --git a/src/kexiutils/KexiStyle.h b/src/kexiutils/KexiStyle.h index 8d27bd9e2..b9e923033 100644 --- a/src/kexiutils/KexiStyle.h +++ b/src/kexiutils/KexiStyle.h @@ -1,73 +1,105 @@ /* This file is part of the KDE project Copyright (C) 2016 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KEXISTYLE_H #define KEXISTYLE_H #include +#include + +#include + class QFont; class QFrame; +class QIcon; class QModelIndex; class QPainter; class QPalette; class QRect; class QStyleOptionViewItem; class QWidget; +//! Styled icon parameters +class KEXIUTILS_EXPORT KexiStyledIconParameters { +public: + explicit KexiStyledIconParameters(KIconLoader::Context c = KIconLoader::Action) : context(c) + { + } + //! Icon name + QString name; + //! Icon color, when used for normal mode (QIcon::Normal). + //! If the value is valid, default color will be replaced with it. + QColor color; + //! Icon color, when used for selected mode (QIcon::Selected). + //! If the value is valid, default color will be replaced with it. + QColor selectedColor; + //! Icon context such as "actions" + KIconLoader::Context context; +}; + //! Application style. //! @todo make it configurable? namespace KexiStyle { //! Setup style for @a frame. By default flat style is set (QFrame::NoFrame). KEXIUTILS_EXPORT void setupFrame(QFrame *frame); //! Setup style for the global mode selector widget (KexiModeSelector). //! By default setupFrame() is called to set flat style, minimal fonts are set - //! and alternativePalette(). + //! and a bit darker version of alternativePalette(). KEXIUTILS_EXPORT void setupModeSelector(QFrame *selector); //! Overpaints entire mode selector. By default it paints a dark shadow an arrow //! for selected item. If @a selectedRect is not null, provides geometry of selected item. KEXIUTILS_EXPORT void overpaintModeSelector(QWidget *widget, QPainter *painter, const QRect &selectedRect); //! Overpaints mode selector's item. By default does nothing. KEXIUTILS_EXPORT void overpaintModeSelectorItem(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index); //! @return alternative palette based on @a palette. //! By default it is dark one based on Breeze colors. KEXIUTILS_EXPORT QPalette alternativePalette(const QPalette &palette); //! @return palette dedicated for side bars, based on @a palette. //! By default it equal to alternativePalette(). KEXIUTILS_EXPORT QPalette sidebarsPalette(const QPalette &palette); //! Sets sidebarsPalette(). If it's nonstandard palette, //! QWidget::setAutoFillBackground(true) is also called for the widget. KEXIUTILS_EXPORT void setSidebarsPalette(QWidget *widget); //! @return font @a font adjusted to make it a title font. //! By default capitalization is set for the font. KEXIUTILS_EXPORT QFont titleFont(const QFont &font); + + //! @return styled dark icon @a iconName of context @a iconContext. Group can be "actions", etc. + //! The same styled icon can be used with light and dark background. Filename for dark + //! variants should have "@dark" suffix. + //! KIconLoader::Any means KIconLoader::Action. + KEXIUTILS_EXPORT QIcon darkIcon(const QString &iconName, + KIconLoader::Context iconContext = KIconLoader::Action); + + KEXIUTILS_EXPORT QIcon icon(const KexiStyledIconParameters ¶meters); } #endif // KEXISTYLE_H diff --git a/src/kexiutils/utils.h b/src/kexiutils/utils.h index b7e7742b5..ac4885194 100644 --- a/src/kexiutils/utils.h +++ b/src/kexiutils/utils.h @@ -1,639 +1,652 @@ /* This file is part of the KDE project Copyright (C) 2003-2016 Jarosław Staniek Contains code from kglobalsettings.h: Copyright (C) 2000, 2006 David Faure Copyright (C) 2008 Friedrich W. H. Kossebau Contains code from kdialog.h: Copyright (C) 1998 Thomas Tanghus (tanghus@earthling.net) Additions 1999-2000 by Espen Sand (espen@kde.org) and Holger Freyther 2005-2009 Olivier Goffart 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KEXIUTILS_UTILS_H #define KEXIUTILS_UTILS_H #include "kexiutils_export.h" #include "kexi_global.h" #include #include #include #include #include #include #include #include #include class QColor; class QMetaProperty; class QLayout; class QLineEdit; class KLocalizedString; //! @short General Utils namespace KexiUtils { //! \return true if parent of \a o that is of type \a className or false otherwise inline bool parentIs(QObject* o, const char* className = 0) { if (!o) return false; while ((o = o->parent())) { if (o->inherits(className)) return true; } return false; } //! \return parent object of \a o that is of type \a type or 0 if no such parent template inline type findParentByType(QObject* o) { if (!o) return 0; while ((o = o->parent())) { if (dynamic_cast< type >(o)) return dynamic_cast< type >(o); } return 0; } /*! \return first found child of \a o, inheriting \a className. If objName is 0 (the default), all object names match. Returned pointer type is casted. */ KEXIUTILS_EXPORT QObject* findFirstQObjectChild(QObject *o, const char* className, const char* objName); /*! \return first found child of \a o, that inherit \a className. If \a objName is 0 (the default), all object names match. Returned pointer type is casted. */ template inline type findFirstChild(QObject *o, const char* className, const char* objName = 0) { return ::qobject_cast< type >(findFirstQObjectChild(o, className, objName)); } //! Finds property for name \a name and object \a object returns it index; //! otherwise returns a null QMetaProperty. KEXIUTILS_EXPORT QMetaProperty findPropertyWithSuperclasses(const QObject* object, const char* name); //! \return true if \a object object is of class name \a className inline bool objectIsA(QObject* object, const char* className) { return 0 == qstrcmp(object->metaObject()->className(), className); } //! \return true if \a object object is of the class names inside \a classNames KEXIUTILS_EXPORT bool objectIsA(QObject* object, const QList& classNames); //! \return a list of methods for \a metaObject meta object. //! The methods are of type declared in \a types and have access declared //! in \a access. KEXIUTILS_EXPORT QList methodsForMetaObject( const QMetaObject *metaObject, QFlags types = QFlags(QMetaMethod::Method | QMetaMethod::Signal | QMetaMethod::Slot), QFlags access = QFlags(QMetaMethod::Private | QMetaMethod::Protected | QMetaMethod::Public)); //! Like \ref KexiUtils::methodsForMetaObject() but includes methods from all //! parent meta objects of the \a metaObject. KEXIUTILS_EXPORT QList methodsForMetaObjectWithParents( const QMetaObject *metaObject, QFlags types = QFlags(QMetaMethod::Method | QMetaMethod::Signal | QMetaMethod::Slot), QFlags access = QFlags(QMetaMethod::Private | QMetaMethod::Protected | QMetaMethod::Public)); //! \return a list with all this class's properties. KEXIUTILS_EXPORT QList propertiesForMetaObject( const QMetaObject *metaObject); //! \return a list with all this class's properties including thise inherited. KEXIUTILS_EXPORT QList propertiesForMetaObjectWithInherited( const QMetaObject *metaObject); //! \return a list of enum keys for meta property \a metaProperty. KEXIUTILS_EXPORT QStringList enumKeysForProperty(const QMetaProperty& metaProperty); //! Convert a list @a list of @a SourceType type to another list of @a DestinationType //! type using @a convertMethod function /*! Example: @code QList list = ....; QStringList result = KexiUtils::convertTypesUsingFunction(list); @endcode */ template QList convertTypesUsingFunction(const QList &list) { QList result; foreach(const SourceType &element, list) { result.append(ConvertFunction(element)); } return result; } //! Convert a list @a list of @a SourceType type to another list of @a DestinationType //! type using @a convertMethod /*! Example: @code QVariantList list = ....; QStringList result = KexiUtils::convertTypesUsingMethod(list); @endcode */ template QList convertTypesUsingMethod(const QList &list) { QList result; foreach(const SourceType &element, list) { result.append((element.*ConvertMethod)()); } return result; } /*! Sets "wait" cursor with 1 second delay (or 0 seconds if noDelay is true). Does nothing if the application has no GUI enabled. (see KApplication::guiEnabled()) */ KEXIUTILS_EXPORT void setWaitCursor(bool noDelay = false); /*! Remove "wait" cursor previously set with \a setWaitCursor(), even if it's not yet visible. Does nothing if the application has no GUI enabled. (see KApplication::guiEnabled()) */ KEXIUTILS_EXPORT void removeWaitCursor(); /*! Helper class. Allocate it in your code block as follows: KexiUtils::WaitCursor wait; .. and wait cursor will be visible (with one second delay) until you're in this block, without a need to call removeWaitCursor() before exiting the block. Does nothing if the application has no GUI enabled. (see KApplication::guiEnabled()) */ class KEXIUTILS_EXPORT WaitCursor { public: WaitCursor(bool noDelay = false); ~WaitCursor(); }; /*! Helper class. Allocate it in your code block as follows: KexiUtils::WaitCursorRemover remover; .. and the wait cursor will be hidden unless you leave this block, without a need to call setWaitCursor() before exiting the block. After leaving the codee block, the cursor will be visible again, if it was visible before creating the WaitCursorRemover object. Does nothing if the application has no GUI enabled. (see KApplication::guiEnabled()) */ class KEXIUTILS_EXPORT WaitCursorRemover { public: WaitCursorRemover(); ~WaitCursorRemover(); private: bool m_reactivateCursor; }; /*! \return filter string in QFileDialog format for a mime type pointed by \a mime If \a kdeFormat is true, QFileDialog-compatible filter string is generated, eg. "Image files (*.png *.xpm *.jpg)", otherwise KFileDialog -compatible filter string is generated, eg. "*.png *.xpm *.jpg|Image files (*.png *.xpm *.jpg)". "\\n" is appended if \a kdeFormat is true, otherwise ";;" is appended. */ KEXIUTILS_EXPORT QString fileDialogFilterString(const QMimeType &mime, bool kdeFormat = true); /*! @overload QString fileDialogFilterString(const QMimeType &mime, bool kdeFormat = true) */ KEXIUTILS_EXPORT QString fileDialogFilterString(const QString& mimeName, bool kdeFormat = true); /*! Like QString fileDialogFilterString(const QMimeType &mime, bool kdeFormat = true) but returns a list of filter strings. */ KEXIUTILS_EXPORT QString fileDialogFilterStrings(const QStringList& mimeStrings, bool kdeFormat); /*! Creates a modal file dialog which returns the selected url of image filr to open or an empty string if none was chosen. Like KFileDialog::getImageOpenUrl(). */ //! @todo KEXI3 add equivalent of kfiledialog:/// KEXIUTILS_EXPORT QUrl getOpenImageUrl(QWidget *parent = 0, const QString &caption = QString(), const QUrl &directory = QUrl()); /*! Creates a modal file dialog with returns the selected url of image file to save or an empty string if none was chosen. Like KFileDialog::getSaveUrl(). */ //! @todo KEXI3 add equivalent of kfiledialog:/// KEXIUTILS_EXPORT QUrl getSaveImageUrl(QWidget *parent = 0, const QString &caption = QString(), const QUrl &directory = QUrl()); /*! Displays a "The file %1 already exists. Do you want to overwrite it?" Yes/No message box. @a parent is used as a parent of the message box. @return @c true if @a filePath file does not exist or user has agreed to overwrite it; returns @c false if user does not agree to overwrite it. */ KEXIUTILS_EXPORT bool askForFileOverwriting(const QString& filePath, QWidget *parent = nullptr); /*! A global setting for minimal readable font. This can be used in dockers, rulers and other places where space is at a premium. @see QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont). @todo Add integration with KDE platform theme (how to detect it?); for now we don't assume it's installed */ KEXIUTILS_EXPORT QFont smallestReadableFont(); /*! \return a color being a result of blending \a c1 with \a c2 with \a factor1 and \a factor1 factors: (c1*factor1+c2*factor2)/(factor1+factor2). */ KEXIUTILS_EXPORT QColor blendedColors(const QColor& c1, const QColor& c2, int factor1 = 1, int factor2 = 1); /*! \return a contrast color for a color \a c: If \a c is light color, darker color created using c.dark(200) is returned; otherwise lighter color created using c.light(200) is returned. */ KEXIUTILS_EXPORT QColor contrastColor(const QColor& c); /*! \return a lighter color for a color \a c and a factor \a factor. For colors like Qt::red or Qt::green where hue and saturation are near to 255, hue is decreased so the result will be more bleached. For black color the result is dark gray rather than black. */ KEXIUTILS_EXPORT QColor bleachedColor(const QColor& c, int factor); /*! \return icon set computed as a result of colorizing \a icon pixmap with \a role color of \a palette palette. This function is useful for displaying monochromed icons on the list view or table view header, to avoid bloat, but still have the color compatible with accessibility settings. */ KEXIUTILS_EXPORT QIcon colorizeIconToTextColor(const QPixmap& icon, const QPalette& palette, QPalette::ColorRole role = QPalette::ButtonText); /*! Replaces colors in pixmap @a original using @a color color. Used for coloring bitmaps that have to reflect the foreground color. */ KEXIUTILS_EXPORT void replaceColors(QPixmap* original, const QColor& color); /*! Replaces colors in image @a original using @a color color. Used for coloring bitmaps that have to reflect the foreground color. */ KEXIUTILS_EXPORT void replaceColors(QImage* original, const QColor& color); /*! @return true if curent color scheme is light. Lightness of window background is checked to measure this. */ KEXIUTILS_EXPORT bool isLightColorScheme(); /*! @return alpha value for dimmed color (150). */ KEXIUTILS_EXPORT int dimmedAlpha(); /*! @return palette @a pal with dimmed color @a role. @see dimmedAlpha() */ KEXIUTILS_EXPORT QPalette paletteWithDimmedColor(const QPalette &pal, QPalette::ColorGroup group, QPalette::ColorRole role); /*! @overload paletteWithDimmedColor(const QPalette &, QPalette::ColorGroup, QPalette::ColorRole) */ KEXIUTILS_EXPORT QPalette paletteWithDimmedColor(const QPalette &pal, QPalette::ColorRole role); /*! @return palette altered for indicating "read only" flag. */ KEXIUTILS_EXPORT QPalette paletteForReadOnly(const QPalette &palette); /*! Convenience function that sets background color @a color for widget @a widget. "autoFillBackground" property is set to true for the widget. Background color role is obtained from QWidget::backgroundRole(). */ KEXIUTILS_EXPORT void setBackgroundColor(QWidget *widget, const QColor &color); /*! \return empty (fully transparent) pixmap that can be used as a place for icon of size \a iconGroup */ KEXIUTILS_EXPORT QPixmap emptyIcon(KIconLoader::Group iconGroup); #ifdef KEXI_DEBUG_GUI //! Creates debug window for convenient debugging output KEXIUTILS_EXPORT QWidget *createDebugWindow(QWidget *parent); //! Connects push button action to \a receiver and its \a slot. This allows to execute debug-related actions //! using buttons displayed in the debug window. KEXIUTILS_EXPORT void connectPushButtonActionForDebugWindow(const char* actionName, const QObject *receiver, const char* slot); #endif //! Sets focus for widget \a widget with reason \a reason. KEXIUTILS_EXPORT void setFocusWithReason(QWidget* widget, Qt::FocusReason reason); //! Unsets focus for widget \a widget with reason \a reason. KEXIUTILS_EXPORT void unsetFocusWithReason(QWidget* widget, Qt::FocusReason reason); //! If the application's layout direction, swaps left and right margins. //! @see QGuiApplication::isRightToLeft() void adjustIfRtl(QMargins *margins); //! Draws pixmap @a pixmap on painter @a p using predefined parameters. //! Used in KexiDBImageBox and KexiBlobTableEdit. KEXIUTILS_EXPORT void drawPixmap(QPainter* p, const QMargins& margins, const QRect& rect, const QPixmap& pixmap, Qt::Alignment alignment, bool scaledContents, bool keepAspectRatio, Qt::TransformationMode transformMode = Qt::FastTransformation); //! Scales pixmap @a pixmap on painter @a p using predefined parameters. //! Used in KexiDBImageBox and KexiBlobTableEdit. KEXIUTILS_EXPORT QPixmap scaledPixmap(const QMargins& margins, const QRect& rect, const QPixmap& pixmap, QPoint* pos, Qt::Alignment alignment, bool scaledContents, bool keepAspectRatio, Qt::TransformationMode transformMode = Qt::FastTransformation); //! This function should be used instead of QPixmap::loadFromData(). /** Loads a pixmap from @a data into @a pixmap. First tries to detect format, on failure * tries to load most common formats: png, jpg, bmp, tif. Then tries to load any of format * returned by QImageReader::supportedImageFormats(). * If @a format is provided, only this format is tried. * @return on success. * @note This function exists because QPixmap::loadFromData() not always works when there * are broken image format plugins installed (as it was the case with KRA plugin). * @todo Idea: Support while/black list of supported image formats. It would be useful * for security reasons because files can be loaded from remote locations. * @todo For the black/white list an enum describing local/remote data source is needed. */ KEXIUTILS_EXPORT bool loadPixmapFromData(QPixmap *pixmap, const QByteArray &data, const char *format = nullptr); //! A helper for automatic deleting of contents of containers. template class ContainerDeleter { public: explicit ContainerDeleter(Container& container) : m_container(container) {} ~ContainerDeleter() { clear(); } void clear() { qDeleteAll(m_container); m_container.clear(); } private: Container& m_container; }; /*! A modified QFrame which sets up sunken styled panel frame style depending on the current widget style. The widget also reacts on style changes. */ class KEXIUTILS_EXPORT KTextEditorFrame : public QFrame { Q_OBJECT public: explicit KTextEditorFrame(QWidget * parent = 0, Qt::WindowFlags f = 0); protected: virtual void changeEvent(QEvent *event); }; /** * Returns the number of pixels that should be used between a * dialog edge and the outermost widget(s) according to the KDE standard. * * Copied from QDialog. * * @deprecated Use the style's pixelMetric() function to query individual margins. * Different platforms may use different values for the four margins. */ KEXIUTILS_EXPORT int marginHint(); /** * Returns the number of pixels that should be used between * widgets inside a dialog according to the KDE standard. * * Copied from QDialog. * * @deprecated Use the style's layoutSpacing() function to query individual spacings. * Different platforms may use different values depending on widget types and pairs. */ KEXIUTILS_EXPORT int spacingHint(); /*! Sets KexiUtils::marginHint() margins and KexiUtils::spacingHint() spacing for the layout @a layout. */ KEXIUTILS_EXPORT void setStandardMarginsAndSpacing(QLayout *layout); /*! Sets the same @a value for layout @a layout margins. */ KEXIUTILS_EXPORT void setMargins(QLayout *layout, int value); //! sometimes we leave a space in the form of empty QFrame and want to insert here //! a widget that must be instantiated by hand. //! This macro inserts a widget \a what into a frame \a where. #define GLUE_WIDGET(what, where) \ { QVBoxLayout *lyr = new QVBoxLayout(where); \ lyr->addWidget(what); } //! A tool for setting temporary value for boolean variable. /*! After desctruction of the instance, the variable is set back to the original value. This class is useful in recursion guards. To use it, declare class atrribute of type bool and block it, e.g.: @code bool m_myNonRecursiveFunctionEnabled; // ... set m_myNonRecursiveFunctionEnabled initially to true void myNonRecursiveFunctionEnabled() { if (!m_myNonRecursiveFunctionEnabled) return; KexiUtils::BoolBlocker guard(&m_myNonRecursiveFunctionEnabled, false); // function's body guarded against recursion... } @endcode */ class KEXIUTILS_EXPORT BoolBlocker { public: inline BoolBlocker(bool *var, bool tempValue) : v(var), origValue(*var) { *var = tempValue; } inline ~BoolBlocker() { *v = origValue; } private: bool *v; bool origValue; }; /*! This helper function install an event filter on @a object and all of its children, directed to @a filter. */ KEXIUTILS_EXPORT void installRecursiveEventFilter(QObject *object, QObject *filter); /*! This helper function removes an event filter installed before on @a object and all of its children. */ KEXIUTILS_EXPORT void removeRecursiveEventFilter(QObject *object, QObject *filter); //! Blocks paint events on specified widget. /*! Works recursively. Useful when widget should be hidden without changing geometry it takes. */ class KEXIUTILS_EXPORT PaintBlocker : public QObject { Q_OBJECT public: explicit PaintBlocker(QWidget* parent); void setEnabled(bool set); bool enabled() const; protected: virtual bool eventFilter(QObject* watched, QEvent* event); private: bool m_enabled; }; /*! * \short Options for opening of hyperlinks * \sa openHyperLink() */ class KEXIUTILS_EXPORT OpenHyperlinkOptions : public QObject { Q_OBJECT public: /*! * A tool used for opening hyperlinks */ enum HyperlinkTool{ DefaultHyperlinkTool, /*!< Default tool for a given type of the hyperlink */ BrowserHyperlinkTool, /*!< Opens hyperlink in a browser */ MailerHyperlinkTool /*!< Opens hyperlink in a default mailer */ }; Q_ENUM(HyperlinkTool) OpenHyperlinkOptions() : tool(DefaultHyperlinkTool) , allowExecutable(false) , allowRemote(false) {} HyperlinkTool tool; bool allowExecutable; bool allowRemote; }; /*! * Opens the given \a url using \a options * It can fail if opening a given link is not possible or allowed. * @return true on success, cancelled if user has cancelled the opening and false on failure */ KEXIUTILS_EXPORT tristate openHyperLink(const QUrl &url, QWidget *parent, const OpenHyperlinkOptions &options); //! \return size of combo box arrow according to \a style /*! Application's style is the default. \see QStyle::SC_ComboBoxArrow */ KEXIUTILS_EXPORT QSize comboBoxArrowSize(QStyle *style = 0); //! Adds a dirty ("document modified") flag to @a text according to current locale. //! It is usually "*" character appended. KEXIUTILS_EXPORT void addDirtyFlag(QString *text); //! @return The name of the user's preferred encoding //! Based on KLocale::encoding() KEXIUTILS_EXPORT QByteArray encoding(); //! The desired level of effects on the GUI enum GraphicEffect { NoEffects = 0x0000, ///< GUI with no effects at all. GradientEffects = 0x0001, ///< GUI with only gradients enabled. SimpleAnimationEffects = 0x0002, ///< GUI with simple animations enabled. ComplexAnimationEffects = 0x0006 ///< GUI with complex animations enabled. ///< Note that ComplexAnimationsEffects implies SimpleAnimationEffects. }; Q_DECLARE_FLAGS(GraphicEffects, GraphicEffect) //! @return the desired level of effects on the GUI. //! @note A copy of KGlobalSettings::graphicEffectsLevel() needed for porting from kdelibs4. KEXIUTILS_EXPORT GraphicEffects graphicEffectsLevel(); //! @return the inactive titlebar background color //! @note A copy of KGlobalSettings::inactiveTitleColor() needed for porting from kdelibs4. KEXIUTILS_EXPORT QColor inactiveTitleColor(); //! @return the inactive titlebar text (foreground) color //! @note A copy of KGlobalSettings::inactiveTextColor() needed for porting from kdelibs4. KEXIUTILS_EXPORT QColor inactiveTextColor(); //! @return the active titlebar background color //! @note A copy of KGlobalSettings::activeTitleColor() needed for porting from kdelibs4. KEXIUTILS_EXPORT QColor activeTitleColor(); //! @return the active titlebar text (foreground) color //! @note A copy of KGlobalSettings::activeTextColor() needed for porting from kdelibs4. KEXIUTILS_EXPORT QColor activeTextColor(); //! @return Paper White color, see https://techbase.kde.org/Projects/Usability/HIG/Color inline QColor paperWhite() { return QColor(0xfcfcfc); } +//! @return Cardboard Grey color, see https://techbase.kde.org/Projects/Usability/HIG/Color +inline QColor cardboardGrey() { return QColor(0xeff0f1); } + +//! @return Alternative to Normal background (Cardboard Grey), +//! see https://techbase.kde.org/Projects/Usability/HIG/Color +inline QColor cardboardGreyAlternative() { return QColor(0xbdc3c7); } + +//! @return Icon Grey color, see https://techbase.kde.org/Projects/Usability/HIG/Color +inline QColor iconGrey() { return QColor(0x4d4d4d); } + //! @return Charcoal Grey color, see https://techbase.kde.org/Projects/Usability/HIG/Color inline QColor charcoalGrey() { return QColor(0x31363b); } //! @return Shade Black color, see https://techbase.kde.org/Projects/Usability/HIG/Color inline QColor shadeBlack() { return QColor(0x232629); } //! @return Shade Black color made a bit ligher. suitable for alternate base, //! see https://techbase.kde.org/Projects/Usability/HIG/Color inline QColor shadeBlackLighter() { return shadeBlack().lighter(125); } +//! @return Shade Black color, see https://techbase.kde.org/Projects/Usability/HIG/Color +inline QColor plasmaBlue() { return QColor(0x3daee9); } + /*! @return @c true if whether the app runs in a single click mode (the default). @c false if returned if the app runs in double click mode. The flag is checked in two stages. Stage 1. Application config file's "SingleClickOpensItem" value in "MainWindow" group is checked. If it exists, the value is returned. On Windows if it does not exist, @c true is returned, on other systems Stage 2 checking is performed. Stage 2. For Qt < 5.5 this information is taken from @a widget widget's style. If there is no widget specified, QApplication::style() is used. For Qt >= 5.5 the result is equal to QApplication::styleHints()->singleClickActivation() and @a widget is ignored. @note This is a replacement for bool KGlobalSettings::singleClick(). */ KEXIUTILS_EXPORT bool activateItemsOnSingleClick(QWidget *widget = 0); /** * @enum CaptionFlag * Used to specify how to construct a window caption * * @value AppNameCaption Indicates that the method shall include * the application name when making the caption string. * @value ModifiedCaption Causes a 'modified' sign will be included in the * returned string. This is useful when indicating that a file is * modified, i.e., it contains data that has not been saved. */ enum CaptionFlag { NoCaptionFlags = 0, AppNameCaption = 1, ModifiedCaption = 2 }; Q_DECLARE_FLAGS(CaptionFlags, CaptionFlag) /** * Builds a caption that contains the application name along with the * userCaption using a standard layout. * * To make a compliant caption for your window, simply do: * @p setWindowTitle(makeStandardCaption(yourCaption)); * * To ensure that the caption is appropriate to the desktop in which the * application is running, pass in a pointer to the window the caption will * be applied to. * * @param userCaption The caption string you want to display in the * window caption area. Do not include the application name! * @param flags * @return the created caption * Based on KDialog::makeStandardCaption() */ KEXIUTILS_EXPORT QString makeStandardCaption(const QString &userCaption, CaptionFlags flags = AppNameCaption); /** * Return rich text for @a string. Equivalent of KLocalizedString::toString(Kuit::RichText) * but and is removed so the result can be used as %* argument in other string. */ KEXIUTILS_EXPORT QString localizedStringToHtmlSubstring(const KLocalizedString& string); /** * @return @c true if text cursor is at the end of the line edit @a lineEdit. * If the @a lineEdit edit has input mask, cursor is at the end if it's at position * lineEdit->displayText().length() - 1 or further. If the @a lineEdit has no input mask, cursor * is at the end if it's at position lineEdit->text().length() or further. */ KEXIUTILS_EXPORT bool cursorAtEnd(const QLineEdit *lineEdit); } //namespace KexiUtils #endif //KEXIUTILS_UTILS_H