Commit 7a39e413 authored by Eike Hein's avatar Eike Hein
Browse files

Initial port to Frameworks 5.

TODO:
* Finish porting the first run dialog (needs a QDialogButtonBox
  and some visual polish).
* Port skin listing and management away from KIO::NetAccess to
  the jobs API.
* Minor bits and pieces (mainly KDialog->QDialog, e.g. signals).

All unported things are commented out and marked with PORT, so
grep for that if you'd like to help.
parent b2c80bd6
project(yakuake)
set(KDE_MIN_VERSION "4.7.1")
cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
set (QT_MIN_VERSION "5.2.0")
find_package(KDE4 ${KDE_MIN_VERSION} REQUIRED)
find_package(ECM 0.0.9 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(KDE4Defaults)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings)
include(ECMInstallIcons)
include(FeatureSummary)
add_subdirectory( app )
add_subdirectory( data )
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Widgets)
find_package(KF5 CONFIG REQUIRED
Archive
Config
CoreAddons
DBusAddons
GlobalAccel
I18n
IconThemes
KIO
NewStuff
Notifications
NotifyConfig
Parts
WidgetsAddons
WindowSystem
)
find_package(X11)
set(HAVE_X11 ${X11_FOUND})
if(X11_FOUND)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED X11Extras)
endif(X11_FOUND)
add_definitions(
-DQT_USE_QSTRINGBUILDER
-DQT_NO_CAST_TO_ASCII
-DQT_NO_CAST_FROM_ASCII
-DQT_STRICT_ITERATORS
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_CAST_FROM_BYTEARRAY
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
-DQT_USE_FAST_OPERATOR_PLUS
)
add_subdirectory(app)
add_subdirectory(data)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
include_directories( ${KDE4_INCLUDES} )
configure_file(config-yakuake.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-yakuake.h)
set(yakuake_SRCS
main.cpp
application.cpp
mainwindow.cpp
skin.cpp
titlebar.cpp
......@@ -18,24 +17,39 @@ set(yakuake_SRCS
config/skinlistdelegate.cpp
)
kde4_add_kcfg_files(yakuake_SRCS config/settings.kcfgc)
kde4_add_ui_files(yakuake_SRCS
qt5_wrap_ui(yakuake_SRCS
firstrundialog.ui
config/windowsettings.ui
config/behaviorsettings.ui
config/appearancesettings.ui
)
kde4_add_app_icon(yakuake_SRCS "icons/hi*-app-yakuake.png")
kde4_add_executable(yakuake ${yakuake_SRCS})
target_link_libraries(yakuake ${KDE4_KNOTIFYCONFIG_LIBRARY} ${KDE4_KPARTS_LIBS} ${KDE4_KNEWSTUFF3_LIBS})
if(Q_WS_X11)
target_link_libraries(yakuake ${X11_X11_LIB})
endif(Q_WS_X11)
kconfig_add_kcfg_files(yakuake_SRCS config/settings.kcfgc)
# PORT kde4_add_app_icon(yakuake_SRCS "icons/hi*-app-yakuake.png")
add_executable(yakuake ${yakuake_SRCS})
target_link_libraries(yakuake
Qt5::Widgets
KF5::Archive
KF5::ConfigGui
KF5::CoreAddons
KF5::DBusAddons
KF5::GlobalAccel
KF5::I18n
KF5::IconThemes
KF5::KIOCore
KF5::NewStuff
KF5::Notifications
KF5::NotifyConfig
KF5::Parts
KF5::WidgetsAddons
KF5::WindowSystem)
if(X11_FOUND)
target_link_libraries(yakuake Qt5::X11Extras ${X11_X11_LIB})
endif(X11_FOUND)
install(TARGETS yakuake ${INSTALL_TARGETS_DEFAULT_ARGS})
......
/*
Copyright (C) 2008-2009 by Eike Hein <hein@kde.org>
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) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor appro-
ved by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
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, see http://www.gnu.org/licenses/.
*/
#include "application.h"
#include "mainwindow.h"
Application::Application() : KUniqueApplication()
{
m_mainWindow = 0;
}
Application::~Application()
{
}
int Application::newInstance()
{
if (!m_mainWindow)
{
m_mainWindow = new MainWindow();
m_mainWindow->hide();
}
else
m_mainWindow->toggleWindowState();
return 0;
}
/*
Copyright (C) 2008-2009 by Eike Hein <hein@kde.org>
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) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor appro-
ved by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
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, see http://www.gnu.org/licenses/.
*/
#ifndef APPLICATION_H
#define APPLICATION_H
#include <KUniqueApplication>
class MainWindow;
class Application : public KUniqueApplication
{
Q_OBJECT
public:
explicit Application();
virtual ~Application();
virtual int newInstance();
private:
MainWindow* m_mainWindow;
};
#endif
#cmakedefine01 HAVE_X11
......@@ -23,19 +23,18 @@
#include "settings.h"
#include "skinlistdelegate.h"
#include <KApplication>
#include <KFileDialog>
#include <KIO/DeleteJob>
#include <KIO/NetAccess>
#include <KLocalizedString>
#include <KMessageBox>
#include <KStandardDirs>
#include <KTar>
#include <KUrl>
#include <KNS3/DownloadDialog>
#include <knewstuff3/downloadmanager.h>
#include <KNS3/DownloadManager>
#include <QDir>
#include <QFile>
#include <QFileDialog>
#include <QPointer>
#include <QStandardItemModel>
#include <unistd.h>
......@@ -61,9 +60,9 @@ AppearanceSettings::AppearanceSettings(QWidget* parent) : QWidget(parent)
connect(installButton, SIGNAL(clicked()), this, SLOT(installSkin()));
connect(removeButton, SIGNAL(clicked()), this, SLOT(removeSelectedSkin()));
installButton->setIcon(KIcon("folder"));
removeButton->setIcon(KIcon("edit-delete"));
ghnsButton->setIcon(KIcon("get-hot-new-stuff"));
installButton->setIcon(QIcon(QStringLiteral("folder")));
removeButton->setIcon(QIcon(QStringLiteral("edit-delete")));
ghnsButton->setIcon(QIcon(QStringLiteral("get-hot-new-stuff")));
m_knsConfigFileName = QLatin1String("yakuake.knsrc");
m_knsDownloadManager = new KNS3::DownloadManager(m_knsConfigFileName);
......@@ -75,8 +74,8 @@ AppearanceSettings::AppearanceSettings(QWidget* parent) : QWidget(parent)
// Get all local skin directories.
// One for manually installed skins, one for skins installed
// through KNS3.
m_localSkinsDir = KStandardDirs::locateLocal("data", "yakuake/skins/");
m_knsSkinDir = KStandardDirs::locateLocal("data", "yakuake/kns_skins/");
m_localSkinsDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/yakuake/skins/");
m_knsSkinDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/yakuake/kns_skins/");
populateSkinList();
}
......@@ -99,11 +98,11 @@ void AppearanceSettings::populateSkinList()
{
m_skins->clear();
QStringList titleDirs = KGlobal::dirs()->findAllResources("data", "yakuake/skins/*/title.skin")
+ KGlobal::dirs()->findAllResources("data", m_knsSkinDir + "*/title.skin");
QStringList tabDirs = KGlobal::dirs()->findAllResources("data", "yakuake/skins/*/tabs.skin")
+ KGlobal::dirs()->findAllResources("data", m_knsSkinDir + "*/tabs.skin");
// PORT QStringList titleDirs = KGlobal::dirs()->findAllResources("data", "yakuake/skins/*/title.skin")
// PORT + KGlobal::dirs()->findAllResources("data", m_knsSkinDir + "*/title.skin");
// PORT QStringList tabDirs = KGlobal::dirs()->findAllResources("data", "yakuake/skins/*/tabs.skin")
// PORT + KGlobal::dirs()->findAllResources("data", m_knsSkinDir + "*/tabs.skin");
/* PORT
QStringList skinDirs;
QStringListIterator i(titleDirs);
......@@ -142,11 +141,12 @@ void AppearanceSettings::populateSkinList()
m_skins->sort(0);
updateRemoveSkinButton();
*/
}
QStandardItem* AppearanceSettings::createSkinItem(const QString& skinDir)
{
QString skinId = skinDir.section('/', -1, -1);
QString skinId = skinDir.section(QStringLiteral("/"), -1, -1);
QString titleName, tabName, skinName;
QString titleAuthor, tabAuthor, skinAuthor;
QString titleIcon, tabIcon;
......@@ -156,10 +156,10 @@ QStandardItem* AppearanceSettings::createSkinItem(const QString& skinDir)
// KNS3 skins are found in.
bool isKnsSkin = skinDir.startsWith(m_knsSkinDir);
KConfig titleConfig(skinDir + "/title.skin", KConfig::SimpleConfig);
KConfig titleConfig(skinDir + QStringLiteral("/title.skin"), KConfig::SimpleConfig);
KConfigGroup titleDescription = titleConfig.group("Description");
KConfig tabConfig(skinDir + "/tabs.skin", KConfig::SimpleConfig);
KConfig tabConfig(skinDir + QStringLiteral("/tabs.skin"), KConfig::SimpleConfig);
KConfigGroup tabDescription = tabConfig.group("Description");
titleName = titleDescription.readEntry("Skin", "");
......@@ -178,7 +178,7 @@ QStandardItem* AppearanceSettings::createSkinItem(const QString& skinDir)
skinName = skinId;
if (skinAuthor.isEmpty())
skinAuthor = i18nc("@item:inlistbox Unknown skin author", "Unknown");
skinAuthor = xi18nc("@item:inlistbox Unknown skin author", "Unknown");
QStandardItem* skin = new QStandardItem(skinName);
......@@ -216,17 +216,18 @@ void AppearanceSettings::resetSelection()
void AppearanceSettings::installSkin()
{
/* PORT
QString mimeFilter = "application/x-tar application/x-compressed-tar "
"application/x-bzip-compressed-tar application/zip";
KUrl skinUrl = KFileDialog::getOpenUrl(KUrl(), mimeFilter, parentWidget());
QUrl skinUrl = QFileDialog::getOpenFileUrl(parentWidget());
if (skinUrl.isEmpty()) return;
if (!KIO::NetAccess::download(skinUrl, m_installSkinFile, KApplication::activeWindow()))
if (!KIO::NetAccess::download(skinUrl, m_installSkinFile, QApplication::activeWindow()))
{
KMessageBox::error(parentWidget(), KIO::NetAccess::lastErrorString(),
i18nc("@title:window", "Failed to Download Skin"));
xi18nc("@title:window", "Failed to Download Skin"));
return;
}
......@@ -235,7 +236,7 @@ void AppearanceSettings::installSkin()
if (!skinDir.exists())
{
KIO::ListJob* job = KIO::listRecursive("tar:" + m_installSkinFile, KIO::HideProgressInfo, false);
KIO::ListJob* job = KIO::listRecursive(QUrl("tar:" + m_installSkinFile), KIO::HideProgressInfo, false);
connect(job, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)),
this, SLOT(listSkinArchive(KIO::Job*,KIO::UDSEntryList)));
......@@ -243,7 +244,8 @@ void AppearanceSettings::installSkin()
connect(job, SIGNAL(result(KJob*)), this, SLOT(validateSkinArchive(KJob*)));
}
else
failInstall(i18nc("@info", "The installer was given a directory, not a file."));
failInstall(xi18nc("@info", "The installer was given a directory, not a file."));
*/
}
void AppearanceSettings::listSkinArchive(KIO::Job* /* job */, const KIO::UDSEntryList& list)
......@@ -265,18 +267,18 @@ void AppearanceSettings::validateSkinArchive(KJob* job)
if (validateSkin(m_installSkinId, m_installSkinFileList))
checkForExistingSkin();
else
failInstall(i18nc("@info", "Unable to locate required files in the skin archive.<nl/><nl/>The archive appears to be invalid."));
failInstall(xi18nc("@info", "Unable to locate required files in the skin archive.<nl/><nl/>The archive appears to be invalid."));
}
else
failInstall(i18nc("@info", "Unable to list the skin archive contents.") + "\n\n" + job->errorString());
failInstall(xi18nc("@info", "Unable to list the skin archive contents.") + QStringLiteral("\n\n") + job->errorString());
}
bool AppearanceSettings::validateSkin(const QString &skinId, const QStringList& fileList)
{
bool titleFileFound = false;
bool tabsFileFound = false;
QString titleFileName = skinId + "/title.skin";
QString tabsFileName = skinId + "/tabs.skin";
QString titleFileName = skinId + QStringLiteral("/title.skin");
QString tabsFileName = skinId + QStringLiteral("/tabs.skin");
foreach (const QString& fileName, fileList)
{
......@@ -309,25 +311,25 @@ void AppearanceSettings::checkForExistingSkin()
if (exists > 0)
{
QString skinDir = skins.at(0).data(SkinDir).toString();
QFile skin(skinDir + "/titles.skin");
QFile skin(skinDir + QStringLiteral("/titles.skin"));
if (!skin.open(QIODevice::ReadWrite))
{
failInstall(i18nc("@info", "This skin appears to be already installed and you lack the required permissions to overwrite it."));
failInstall(xi18nc("@info", "This skin appears to be already installed and you lack the required permissions to overwrite it."));
}
else
{
skin.close();
int remove = KMessageBox::warningContinueCancel(parentWidget(),
i18nc("@info", "This skin appears to be already installed. Do you want to overwrite it?"),
i18nc("@title:window", "Skin Already Exists"),
KGuiItem(i18nc("@action:button", "Reinstall Skin")));
xi18nc("@info", "This skin appears to be already installed. Do you want to overwrite it?"),
xi18nc("@title:window", "Skin Already Exists"),
KGuiItem(xi18nc("@action:button", "Reinstall Skin")));
if (remove == KMessageBox::Continue)
{
unlink(QFile::encodeName(skinDir));
KIO::DeleteJob* job = KIO::del(KUrl(skinDir), KIO::HideProgressInfo);
//PORTunlink(QFile::encodeName(skinDir));
KIO::DeleteJob* job = KIO::del(QUrl(skinDir), KIO::HideProgressInfo);
connect(job, SIGNAL(result(KJob*)), this, SLOT(installSkinArchive(KJob*)));
}
else
......@@ -342,7 +344,7 @@ void AppearanceSettings::installSkinArchive(KJob* deleteJob)
{
if (deleteJob && deleteJob->error())
{
KMessageBox::error(parentWidget(), deleteJob->errorString(), i18nc("@title:Window", "Could Not Delete Skin"));
KMessageBox::error(parentWidget(), deleteJob->errorString(), xi18nc("@title:Window", "Could Not Delete Skin"));
return;
}
......@@ -363,22 +365,24 @@ void AppearanceSettings::installSkinArchive(KJob* deleteJob)
cleanupAfterInstall();
}
else
failInstall(i18nc("@info", "The skin archive file could not be opened."));
failInstall(xi18nc("@info", "The skin archive file could not be opened."));
}
void AppearanceSettings::failInstall(const QString& error)
{
KMessageBox::error(parentWidget(), error, i18nc("@title:window", "Cannot Install Skin"));
KMessageBox::error(parentWidget(), error, xi18nc("@title:window", "Cannot Install Skin"));
cleanupAfterInstall();
}
void AppearanceSettings::cleanupAfterInstall()
{
/* PORT
KIO::NetAccess::removeTempFile(m_installSkinFile);
m_installSkinId.clear();
m_installSkinFile.clear();
m_installSkinFileList.clear();
*/
}
void AppearanceSettings::updateRemoveSkinButton()
......@@ -406,7 +410,7 @@ void AppearanceSettings::updateRemoveSkinButton()
return;
}
QFile titleSkin(skinDir + "/title.skin");
QFile titleSkin(skinDir + QStringLiteral("/title.skin"));
if (!titleSkin.open(QIODevice::ReadWrite))
removeButton->setEnabled(false);
......@@ -418,6 +422,7 @@ void AppearanceSettings::updateRemoveSkinButton()
void AppearanceSettings::removeSelectedSkin()
{
/* PORT
if (m_skins->rowCount() <= 1) return;
QString skinId = skinList->currentIndex().data(SkinId).toString();
......@@ -428,15 +433,15 @@ void AppearanceSettings::removeSelectedSkin()
if (skinDir.isEmpty()) return;
int remove = KMessageBox::warningContinueCancel(parentWidget(),
i18nc("@info", "Do you want to remove \"%1\" by %2?", skinName, skinAuthor),
i18nc("@title:window", "Remove Skin"),
xi18nc("@info", "Do you want to remove \"%1\" by %2?", skinName, skinAuthor),
xi18nc("@title:window", "Remove Skin"),
KStandardGuiItem::del());
if (remove == KMessageBox::Continue)
{
unlink(QFile::encodeName(skinDir));
bool deleted = KIO::NetAccess::del(KUrl(skinDir), KApplication::activeWindow());
bool deleted = KIO::NetAccess::del(QUrl(skinDir), QApplication::activeWindow());
if (deleted)
{
......@@ -452,8 +457,9 @@ void AppearanceSettings::removeSelectedSkin()
populateSkinList();
}
else
KMessageBox::error(parentWidget(), i18nc("@info", "Could not remove skin \"%1\".", skinName));
KMessageBox::error(parentWidget(), xi18nc("@info", "Could not remove skin \"%1\".", skinName));
}
*/
}
QSet<QString> AppearanceSettings::extractKnsSkinIds(const QStringList& fileList)
......@@ -469,13 +475,13 @@ QSet<QString> AppearanceSettings::extractKnsSkinIds(const QStringList& fileList)
QString relativeName = QString(file).remove(m_knsSkinDir, Qt::CaseInsensitive);
// Get everything before the first slash - that should be our skins ID.
QString skinId = relativeName.section('/', 0, QString::SectionSkipEmpty);
QString skinId = relativeName.section(QStringLiteral("/"), 0, QString::SectionSkipEmpty);
// Skip all other entries in the file list if we found what we were searching for.
if (!skinId.isEmpty())
{
// First remove all remaining slashes (as there could be leading or trailing ones).
skinId = skinId.replace('/', QString());
skinId = skinId.replace(QStringLiteral("/"), QString());
skinIdList.insert(skinId);
}
......@@ -496,7 +502,6 @@ void AppearanceSettings::getNewSkins()
if (dialog.isNull())
{
kDebug() << "KNS3::DownloadDialog was destroyed during exec()!";
return;
}
......@@ -516,8 +521,6 @@ void AppearanceSettings::getNewSkins()
// Validate the current skin.
if (!validateSkin(skinId, entry.installedFiles()))
{
kDebug() << "skinId '" << skinId << "' is invalid "
<< "(it's either missing the 'title.skin' or 'tabs.skin' file).";
isValid = false;
}
}
......@@ -532,7 +535,7 @@ void AppearanceSettings::getNewSkins()
// The user needs to know the name of the skin which
// was removed.
invalidSkinText += QString("<li>%1</li>").arg(entry.name());
invalidSkinText += QString(QStringLiteral("<li>%1</li>")).arg(entry.name());
// Then remove the skin.
m_knsDownloadManager->uninstallEntry(entry);
......@@ -542,7 +545,7 @@ void AppearanceSettings::getNewSkins()
// Are there any invalid entries?
if (invalidEntryCount > 0)
{
failInstall(i18ncp("@info",
failInstall(xi18ncp("@info",
"The following skin is missing required files. Thus it was removed:<ul>%2</ul>",
"The following skins are missing required files. Thus they were removed:<ul>%2</ul>",
invalidEntryCount,
......
......@@ -58,11 +58,11 @@ class AppearanceSettings : public QWidget, private Ui::AppearanceSettings
};
public slots:
public Q_SLOTS:
void resetSelection();
signals:
Q_SIGNALS:
void settingsChanged();
......@@ -70,7 +70,7 @@ class AppearanceSettings : public QWidget, private Ui::AppearanceSettings
virtual void showEvent(QShowEvent* event);
private slots:
private Q_SLOTS:
void populateSkinList();
void updateSkinSetting();
......
......@@ -155,7 +155,7 @@
</property>
<layout class="QGridLayout">
<item row="2" column="0" colspan="2">
<widget class="KPushButton" name="ghnsButton">
<widget class="QPushButton" name="ghnsButton">
<property name="text">
<string comment="@action:button">Get New Skins...</string>
</property>
......@@ -172,14 +172,14 @@
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="KLineEdit" name="kcfg_Skin">
<widget class="QLineEdit" name="kcfg_Skin">
<property name="frame">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KPushButton" name="removeButton">
<widget class="QPushButton" name="removeButton">
<property name="enabled">
<bool>false</bool>
</property>
......@@ -189,7 +189,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="KPushButton" name="installButton">
<widget class="QPushButton" name="installButton">
<property name="enabled">
<bool>true</bool>
</property>
......@@ -216,16 +216,6 @@
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
<customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>kcfg_TerminalHighlightOnManualActivation</tabstop>
......
......@@ -22,6 +22,8 @@
#include "skinlistdelegate.h"
#include "appearancesettings.h"