Unverified Commit ed5a48fc authored by Yichao Yu's avatar Yichao Yu
Browse files

[qt5] get rid of kdelibs4support dependency

parent 0f528efd
......@@ -71,7 +71,7 @@ if(ENABLE_QT5)
ConfigWidgets
FrameworkIntegration
I18n
KDELibs4Support
GuiAddons
KIO
GuiAddons
IconThemes
......
......@@ -1657,8 +1657,8 @@ void qtcDefaultSettings(Options *opts)
}
#ifdef CONFIG_WRITE
#include <KDE/KConfig>
#include <KDE/KConfigGroup>
#include <KConfigCore/KConfig>
#include <KConfigCore/KConfigGroup>
static const char*
toStr(EDefBtnIndicator ind)
......
......@@ -52,8 +52,11 @@ add_library(kstyle_qtcurve5_config MODULE ${kstyle_qtcurve5_config_PART_SRCS})
target_link_libraries(kstyle_qtcurve5_config Qt5::Core Qt5::Gui Qt5::Widgets)
target_link_libraries(kstyle_qtcurve5_config
KF5::Archive
KF5::ConfigCore
KF5::ConfigWidgets
KF5::I18n
KF5::KDELibs4Support
KF5::GuiAddons
KF5::IconThemes
KF5::KIOWidgets
KF5::WidgetsAddons
KF5::XmlGui
......
......@@ -25,10 +25,6 @@
#include <common/common.h>
#include <common/kf5_utils.h>
#include <KLocale>
#include <KUrlRequester>
#include <KFileDialog>
#include <QFile>
#include <QFileInfo>
#include <QGridLayout>
......
......@@ -58,6 +58,8 @@
#include <QTextStream>
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QMimeDatabase>
#include <QMimeType>
#include <QStyleFactory>
#include <QCloseEvent>
#include <QRegExp>
......@@ -72,27 +74,17 @@
#include <klocalizedstring.h>
#include <kactioncollection.h>
#include <kguiitem.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
#include <kcharselect.h>
#include <kstandardaction.h>
#include <ktoolbar.h>
#include <kzip.h>
#include <kmimetype.h>
#include <kcolorscheme.h>
#include <ksharedconfig.h>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kaboutdata.h>
// KDE4 support
#include <KDE/KGlobal>
#include <KDE/KStandardDirs>
// system
#include <mutex>
#include <initializer_list>
#define EXTENSION ".qtcurve"
#define VERSION_WITH_KWIN_SETTINGS qtcMakeVersion(1, 5)
......@@ -1729,11 +1721,25 @@ QtCurveConfig::setupPresets(const Options &currentStyle,
const Options &defaultStyle)
{
// TODO custom filter and figure out what directory to use.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
QStringList files(KGlobal::dirs()->findAllResources("data", "QtCurve/*" EXTENSION, KStandardDirs::NoDuplicates));
#pragma GCC diagnostic pop
QStringList files;
{
// Make unique list of relative paths
QHash<QString, QString> files_map;
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation,
QStringLiteral("QtCurve"),
QStandardPaths::LocateDirectory);
for (const QString &dir: dirs) {
const QDir d(dir);
const QStringList fileNames = d.entryList(QStringList() << QStringLiteral("*" EXTENSION));
for (const QString &file: fileNames) {
if (!files_map.contains(file)) {
auto abspath = d.absoluteFilePath(file);
files_map.insert(file, abspath);
files.append(file);
}
}
}
}
files.sort();
QStringList::Iterator it(files.begin()),
......@@ -2632,14 +2638,14 @@ void QtCurveConfig::deletePreset()
void QtCurveConfig::importPreset()
{
QString file(KFileDialog::getOpenFileName(
QUrl(), i18n("*" EXTENSION "|QtCurve Settings Files\n"
THEME_PREFIX "*" THEME_SUFFIX
"|QtCurve KDE Theme Files"), this));
auto file = QFileDialog::getOpenFileName(this, i18n("Open"), QString(),
i18n("QtCurve Settings Files (*" EXTENSION ");;"
"QtCurve KDE Theme Files (" THEME_PREFIX "*" THEME_SUFFIX ")"));
if (!file.isEmpty()) {
KMimeType::Ptr mimeType=KMimeType::findByFileContent(file);;
bool compressed(mimeType && !mimeType->is("text/plain"));
QMimeDatabase mime_db;
auto mimeType = mime_db.mimeTypeForFile(file, QMimeDatabase::MatchContent);
bool compressed(mimeType.isValid() && !mimeType.inherits("text/plain"));
QString fileName(getFileName(file)),
baseName(fileName.remove(EXTENSION).replace(' ', '_')),
name(QString(baseName).replace('_', ' '));
......@@ -2790,9 +2796,8 @@ void QtCurveConfig::exportPreset()
#endif
bool compressed = haveImages();
QString file(KFileDialog::getSaveFileName(
QUrl(), i18n("*" EXTENSION "|QtCurve Settings Files"),
this));
auto file = QFileDialog::getSaveFileName(this, i18n("Save As"), QString(),
i18n("QtCurve Settings Files (*" EXTENSION ")"));
if (!file.isEmpty()) {
bool rv = [&] {
......
......@@ -21,8 +21,8 @@
*****************************************************************************/
#include "qtcurveconfig.h"
#include <KDE/KConfig>
#include <KDE/KConfigGroup>
#include <KConfigCore/KConfig>
#include <KConfigCore/KConfigGroup>
namespace QtCurve {
namespace KWin {
......
......@@ -20,12 +20,9 @@
* see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
#include <kdeversion.h>
#include <kcolorscheme.h>
#include <KConfig>
#include <KConfigGroup>
#include <KConfigCore/KConfig>
#include <KConfigCore/KConfigGroup>
#include <KConfigWidgets/KColorScheme>
#include <QApplication>
#include "qtcurveshadowconfiguration.h"
......
......@@ -28,9 +28,7 @@
#include <qtcurve-utils/qtutils.h>
#include <kconfig.h>
#include <klocale.h>
#include <kdeversion.h>
#include <KConfigCore/KConfig>
#include <QDBusConnection>
......
......@@ -70,11 +70,13 @@ add_dependencies(qtcurve-qt5 qtc_qt5_check_on_hdr qtc_qt5_check_x_on_hdr
target_link_libraries(qtcurve-qt5 ${QTC_QT5_LINK_LIBS} qtcurve-utils)
if(QTC_QT5_ENABLE_KDE)
target_link_libraries(qtcurve-qt5
KF5::ConfigCore
KF5::GuiAddons
KF5::IconThemes
KF5::KDELibs4Support
KF5::Style
KF5::WidgetsAddons
KF5::WindowSystem
KF5::XmlGui
)
endif()
install(TARGETS qtcurve-qt5 LIBRARY DESTINATION ${QTCURVE_STYLE_DIR})
......
......@@ -76,27 +76,12 @@
#include <sys/time.h>
#ifdef QTC_QT5_ENABLE_KDE
// KDE4 support headers
#include <KDE/KApplication>
#include <KDE/KAboutData>
#include <KDE/KGlobal>
#include <KDE/KGlobalSettings>
#include <KDE/KConfig>
#include <KDE/KConfigGroup>
#include <KDE/KColorScheme>
#include <KDE/KStandardDirs>
#include <KDE/KTitleWidget>
#include <KDE/KTabBar>
#include <KDE/KFileDialog>
#include <KDE/KPassivePopup>
#include <KDE/KXmlGuiWindow>
#include <KDE/KStandardAction>
#include <KDE/KActionCollection>
#include <KDE/KMenu>
#include <KDE/KAboutApplicationDialog>
// KF5 headers
#include <KConfigCore/KSharedConfig>
#include <KWindowSystem/KWindowSystem>
#include <KConfigWidgets/KColorScheme>
#include <KConfigWidgets/KStandardAction>
#include <KXmlGui/KActionCollection>
#include <KXmlGui/KXmlGuiWindow>
#endif
#include <qtcurve-utils/color.h>
......@@ -3959,7 +3944,6 @@ Style::getMdiColors(const QStyleOption *option, bool active) const
Q_UNUSED(option);
KConfigGroup cg(m_kdeGlobals, "WM");
// QColor col = KGlobalSettings::activeTitleColor();
QColor col = cg.readEntry("activeBackground", QColor(48, 174, 232));
if (col != m_backgroundCols[ORIGINAL_SHADE]) {
......@@ -3967,15 +3951,12 @@ Style::getMdiColors(const QStyleOption *option, bool active) const
shadeColors(col, m_activeMdiColors);
}
// col = KGlobalSettings::inactiveTitleColor();
col = cg.readEntry("inactiveBackground", QColor(224, 223, 222));;
if (col != m_backgroundCols[ORIGINAL_SHADE]) {
m_mdiColors = new QColor[TOTAL_SHADES+1];
shadeColors(col, m_mdiColors);
}
// m_activeMdiTextColor = KGlobalSettings::activeTextColor();
// m_mdiTextColor = KGlobalSettings::inactiveTextColor();
m_activeMdiTextColor = cg.readEntry("activeForeground", QColor(255, 255, 255));
m_mdiTextColor = cg.readEntry("inactiveForeground", QColor(75, 71, 67));
#endif
......@@ -4268,15 +4249,15 @@ Style::widgetDestroyed(QObject *o)
}
#ifdef QTC_QT5_ENABLE_KDE
void Style::setupKde4()
{
if(kapp) {
setDecorationColors();
} else {
applyKdeSettings(true);
applyKdeSettings(false);
}
}
// void Style::setupKde4()
// {
// if(kapp) {
// setDecorationColors();
// } else {
// applyKdeSettings(true);
// applyKdeSettings(false);
// }
// }
void
Style::setDecorationColors()
......@@ -4289,57 +4270,57 @@ Style::setDecorationColors()
shadeColors(kcs.decoration(KColorScheme::FocusColor).color(), m_focusCols);
}
void Style::applyKdeSettings(bool pal)
{
if(pal)
{
if(!kapp)
QApplication::setPalette(standardPalette());
setDecorationColors();
}
else
{
KConfigGroup g(m_configFile, "General");
QFont mnu=g.readEntry("menuFont", QApplication::font());
QApplication::setFont(g.readEntry("font", QApplication::font()));
QApplication::setFont(mnu, "QMenuBar");
QApplication::setFont(mnu, "QMenu");
QApplication::setFont(mnu, "KPopupTitle");
QApplication::setFont(g.readEntry("toolBarFont", QApplication::font()), "QToolBar");
}
}
// void Style::applyKdeSettings(bool pal)
// {
// if(pal)
// {
// if(!kapp)
// QApplication::setPalette(standardPalette());
// setDecorationColors();
// }
// else
// {
// KConfigGroup g(m_configFile, "General");
// QFont mnu=g.readEntry("menuFont", QApplication::font());
// QApplication::setFont(g.readEntry("font", QApplication::font()));
// QApplication::setFont(mnu, "QMenuBar");
// QApplication::setFont(mnu, "QMenu");
// QApplication::setFont(mnu, "KPopupTitle");
// QApplication::setFont(g.readEntry("toolBarFont", QApplication::font()), "QToolBar");
// }
// }
#endif
void Style::kdeGlobalSettingsChange(int type, int)
{
#ifndef QTC_QT5_ENABLE_KDE
// TODO
// KDE5 is not emitting this anymore.
// We need our own signal from the configure UI
Q_UNUSED(type);
#else
switch(type) {
case KGlobalSettings::StyleChanged: {
m_configFile->reparseConfiguration();
if (m_usePixmapCache)
QPixmapCache::clear();
init(false);
for (QWidget *widget: QApplication::topLevelWidgets()) {
widget->update();
}
break;
}
case KGlobalSettings::PaletteChanged:
m_configFile->reparseConfiguration();
applyKdeSettings(true);
if (m_usePixmapCache)
QPixmapCache::clear();
break;
case KGlobalSettings::FontChanged:
m_configFile->reparseConfiguration();
applyKdeSettings(false);
break;
}
#endif
// switch(type) {
// case KGlobalSettings::StyleChanged: {
// m_configFile->reparseConfiguration();
// if (m_usePixmapCache)
// QPixmapCache::clear();
// init(false);
// for (QWidget *widget: QApplication::topLevelWidgets()) {
// widget->update();
// }
// break;
// }
// case KGlobalSettings::PaletteChanged:
// m_configFile->reparseConfiguration();
// applyKdeSettings(true);
// if (m_usePixmapCache)
// QPixmapCache::clear();
// break;
// case KGlobalSettings::FontChanged:
// m_configFile->reparseConfiguration();
// applyKdeSettings(false);
// break;
// }
m_blurHelper->setEnabled(Utils::compositingActive());
m_windowManager->initialize(opts.windowDrag);
......
......@@ -372,9 +372,9 @@ private:
void toggleStatusBar(QMainWindow *window);
#ifdef QTC_QT5_ENABLE_KDE
void setupKde4();
// void setupKde4();
void setDecorationColors();
void applyKdeSettings(bool pal);
// void applyKdeSettings(bool pal);
#endif
bool isWindowDragWidget(QObject *o);
void emitMenuSize(QWidget *w, unsigned short size, bool force=false);
......
......@@ -72,15 +72,9 @@
#ifdef QTC_QT5_ENABLE_KDE
#include <QPrintDialog>
#include <KDE/KApplication>
#include <KDE/KGlobal>
#include <KDE/KGlobalSettings>
#include <KDE/KIconLoader>
#include <KDE/KIcon>
#include <KDE/KTitleWidget>
#include <KDE/KTabBar>
#include <KDE/KFileDialog>
#include <KDE/KAboutApplicationDialog>
#include <KIconThemes/KIconLoader>
#include <KWidgetsAddons/KTitleWidget>
#include <KXmlGui/KAboutApplicationDialog>
#endif
#include <qtcurve-utils/color.h>
......@@ -438,9 +432,7 @@ void Style::polish(QPalette &palette)
}
#ifdef QTC_QT5_ENABLE_KDE
// Only set palette here...
if (kapp) {
setDecorationColors();
}
setDecorationColors();
#endif
}
......
......@@ -43,8 +43,7 @@
#include <common/config_file.h>
#ifdef QTC_QT5_ENABLE_KDE
#include <KDE/KIcon>
#include <KDE/KTitleWidget>
#include <KWidgetsAddons/KTitleWidget>
#endif
namespace QtCurve {
......
......@@ -29,8 +29,7 @@
#include <QWindow>
#ifdef QTC_QT5_ENABLE_KDE
# include <kdeversion.h>
# include <KDE/KWindowSystem>
# include <kwindowsystem.h>
#endif
namespace QtCurve {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment