Skip to content

Commit

Permalink
Clean up oldcode and get rid of deprecated warnings.
Browse files Browse the repository at this point in the history
Fix #17
  • Loading branch information
wengxt committed Jun 1, 2020
1 parent 937c2de commit ac28b39
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 89 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(kcm-fcitx)

set(QT_MIN_VERSION "5.3.0")
set(QT_MIN_VERSION "5.11.0")
find_package(ECM 1.0.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(KDEInstallDirs)
Expand All @@ -12,14 +12,13 @@ option(ENABLE_TEST "Enable test" Off)

find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets X11Extras)

find_package(KF5 REQUIRED COMPONENTS
find_package(KF5 5.64 REQUIRED COMPONENTS
CoreAddons
WidgetsAddons
ConfigWidgets
ItemViews
I18n
KIO
NewStuff
)

find_package(FcitxQt5DBusAddons 1.1.0 REQUIRED)
Expand Down
10 changes: 5 additions & 5 deletions layout/keyboardlayoutwidget.cpp
Expand Up @@ -480,7 +480,7 @@ void KeyboardLayoutWidget::init()
}
}

qSort(keyboardItems.begin(), keyboardItems.end(), DrawingItemCompare());
std::sort(keyboardItems.begin(), keyboardItems.end(), DrawingItemCompare());
}

void KeyboardLayoutWidget::initColors()
Expand Down Expand Up @@ -1168,14 +1168,14 @@ void KeyboardLayoutWidget::drawKeyLabel(QPainter* painter, uint keycode, int ang

if (syms[BOTTOMLEFT] == syms[BOTTOMRIGHT] ||
syms[BOTTOMRIGHT].isNull()) {
syms[BOTTOMRIGHT] = QString::null;
syms[BOTTOMRIGHT] = QString();
end[BOTTOMLEFT] = BOTTOMRIGHT;
end[BOTTOMRIGHT] = -1;
}

if (syms[TOPLEFT] == syms[TOPRIGHT] ||
syms[TOPRIGHT].isNull()) {
syms[TOPRIGHT] = QString::null;
syms[TOPRIGHT] = QString();
end[TOPLEFT] = TOPRIGHT;
end[TOPRIGHT] = -1;
}
Expand All @@ -1184,13 +1184,13 @@ void KeyboardLayoutWidget::drawKeyLabel(QPainter* painter, uint keycode, int ang
syms[TOPLEFT].isNull()) &&
((end[BOTTOMLEFT] == BOTTOMLEFT && end[TOPLEFT] == TOPLEFT) ||
(end[BOTTOMLEFT] == BOTTOMRIGHT && end[TOPLEFT] == TOPRIGHT))) {
syms[TOPLEFT] = QString::null;
syms[TOPLEFT] = QString();
end[BOTTOMLEFT] = end[TOPLEFT];
end[TOPLEFT] = -1;
}

if (!syms[BOTTOMRIGHT].isNull() && (syms[BOTTOMRIGHT] == syms[TOPRIGHT] || (syms[TOPRIGHT].isNull() && end[TOPRIGHT] != -1))) {
syms[TOPRIGHT] = QString::null;
syms[TOPRIGHT] = QString();
end[BOTTOMRIGHT] = TOPRIGHT;
}

Expand Down
1 change: 1 addition & 0 deletions layout/keyboardlayoutwidget.h
Expand Up @@ -3,6 +3,7 @@
#ifndef KEYBOARDLAYOUTWIDGET_H
#define KEYBOARDLAYOUTWIDGET_H

#include <QPainterPath>
#include <QWidget>
#include <QMap>
#include <QAbstractNativeEventFilter>
Expand Down
5 changes: 0 additions & 5 deletions src/CMakeLists.txt
Expand Up @@ -40,7 +40,6 @@ target_link_libraries(kcm_fcitx
KF5::I18n
KF5::KIOCore
KF5::KIOWidgets
KF5::NewStuff
FcitxQt5::WidgetsAddons
FcitxQt5::DBusAddons
${FCITX4_FCITX_UTILS_LIBRARIES}
Expand All @@ -57,10 +56,6 @@ fcitx_translate_add_apply_source(
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kcm_fcitx.desktop"
DESTINATION ${CMAKE_INSTALL_KSERVICES5DIR})

message("GHNS DIR : ${CONFIG_INSTALL_DIR}")

install(FILES fcitx-skin.knsrc DESTINATION ${CONFIG_INSTALL_DIR})

if(ENABLE_TEST)
add_subdirectory(test)
endif(ENABLE_TEST)
2 changes: 1 addition & 1 deletion src/addonselector.cpp
Expand Up @@ -272,7 +272,7 @@ QSize AddonSelector::Private::AddonDelegate::sizeHint(const QStyleOptionViewItem
QFont font = titleFont(option.font);
QFontMetrics fmTitle(font);

return QSize(fmTitle.width(index.model()->data(index, Qt::DisplayRole).toString()) +
return QSize(fmTitle.horizontalAdvance(index.model()->data(index, Qt::DisplayRole).toString()) +
0 + MARGIN * i + pushButton->sizeHint().width() * j,
fmTitle.height() + option.fontMetrics.height() + MARGIN * 2);
}
Expand Down
20 changes: 10 additions & 10 deletions src/addonselector_p.h
Expand Up @@ -87,10 +87,10 @@ class AddonSelector::Private::AddonModel : public QAbstractListModel
AddonModel(AddonSelector::Private *addonSelector_d, QObject* parent = 0);
virtual ~AddonModel();

virtual QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
void addAddon(FcitxAddon* addon);

private:
Expand All @@ -108,8 +108,8 @@ class AddonSelector::Private::ProxyModel
virtual ~ProxyModel();

protected:
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
virtual bool subSortLessThan(const QModelIndex& left, const QModelIndex& right) const;
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
bool subSortLessThan(const QModelIndex& left, const QModelIndex& right) const override;

private:
AddonSelector::Private* addonSelector_d;
Expand All @@ -124,16 +124,16 @@ class AddonSelector::Private::AddonDelegate
AddonDelegate(AddonSelector::Private *addonSelector_d, QObject* parent = 0);
virtual ~AddonDelegate();

virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;

Q_SIGNALS:
void changed(bool hasChanged);
void configCommitted(const QByteArray& addonName);

protected:
virtual QList< QWidget* > createItemWidgets(const QModelIndex &index) const;
virtual void updateItemWidgets(const QList< QWidget* > widgets, const QStyleOptionViewItem& option, const QPersistentModelIndex& index) const;
QList< QWidget* > createItemWidgets(const QModelIndex &index) const override;
void updateItemWidgets(const QList< QWidget* > widgets, const QStyleOptionViewItem& option, const QPersistentModelIndex& index) const override;

private Q_SLOTS:
void slotStateChanged(bool state);
Expand Down
2 changes: 1 addition & 1 deletion src/erroroverlay.h
Expand Up @@ -32,7 +32,7 @@ public slots:
void onConnectStatusChanged(bool connected);

protected:
bool eventFilter(QObject *object, QEvent *event);
bool eventFilter(QObject *object, QEvent *event) override;

private:
void reposition();
Expand Down
14 changes: 7 additions & 7 deletions src/impage.cpp
Expand Up @@ -633,7 +633,7 @@ void IMPage::Private::addIM(const QModelIndex& index)
for (int i = 0; i < m_list.size(); i ++) {
if (uniqueName == m_list[i].uniqueName()) {
m_list[i].setEnabled(true);
qStableSort(m_list.begin(), m_list.end());
std::stable_sort(m_list.begin(), m_list.end());
emit updateIMList(m_list, uniqueName);
emit changed();
break;
Expand All @@ -649,7 +649,7 @@ void IMPage::Private::removeIM(const QModelIndex& index)
for (int i = 0; i < m_list.size(); i ++) {
if (uniqueName == m_list[i].uniqueName()) {
m_list[i].setEnabled(false);
qStableSort(m_list.begin(), m_list.end());
std::stable_sort(m_list.begin(), m_list.end());
emit updateIMList(m_list, uniqueName);
emit changed();
break;
Expand All @@ -674,8 +674,8 @@ void IMPage::Private::moveDownIM()
}

if (curIMIdx >= 0 && nextIMIdx >= 0 && curIMIdx != nextIMIdx) {
m_list.swap(curIMIdx, nextIMIdx);
qStableSort(m_list.begin(), m_list.end());
m_list.swapItemsAt(curIMIdx, nextIMIdx);
std::stable_sort(m_list.begin(), m_list.end());
emit updateIMList(m_list, curIndex.data(FcitxIMUniqueNameRole).toString());
emit changed();
}
Expand Down Expand Up @@ -720,8 +720,8 @@ void IMPage::Private::moveUpIM()
}

if (curIMIdx >= 0 && nextIMIdx >= 0 && curIMIdx != nextIMIdx) {
m_list.swap(curIMIdx, nextIMIdx);
qStableSort(m_list.begin(), m_list.end());
m_list.swapItemsAt(curIMIdx, nextIMIdx);
std::stable_sort(m_list.begin(), m_list.end());
emit updateIMList(m_list, curIndex.data(FcitxIMUniqueNameRole).toString());
emit changed();
}
Expand All @@ -738,7 +738,7 @@ void IMPage::Private::fetchIMList()
{
if (Global::instance()->inputMethodProxy()) {
m_list = Global::instance()->inputMethodProxy()->iMList();
qStableSort(m_list.begin(), m_list.end());
std::stable_sort(m_list.begin(), m_list.end());
emit updateIMList(m_list, QString());
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/impage_p.h
Expand Up @@ -179,9 +179,9 @@ class IMPage::Private::IMModel : public QAbstractListModel
IMModel(QObject* parent = 0);
virtual ~IMModel();

virtual QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
Q_SIGNALS:
void select(QModelIndex index);
public Q_SLOTS:
Expand Down
4 changes: 2 additions & 2 deletions src/module.cpp
Expand Up @@ -207,7 +207,7 @@ void Module::load()
configDialog->setAttribute(Qt::WA_DeleteOnClose);
configDialog->open();
}
m_arg = QString::null;
m_arg = QString();
}

if (m_imPage)
Expand Down Expand Up @@ -239,7 +239,7 @@ void Module::defaults()
if (m_imPage) {
m_imPage->defaults();
}
changed();
markAsChanged();
}

}
6 changes: 3 additions & 3 deletions src/module.h
Expand Up @@ -72,17 +72,17 @@ class Module : public KCModule
/**
* Overloading the KCModule load() function.
*/
void load();
void load() override;

/**
* Overloading the KCModule save() function.
*/
void save();
void save() override;

/**
* Overloading the KCModule defaults() function.
*/
void defaults();
void defaults() override;

FcitxAddon* findAddonByName(const QString& name);

Expand Down
40 changes: 12 additions & 28 deletions src/skinpage.cpp
Expand Up @@ -25,9 +25,6 @@
#include <QPointer>
#include <QLineEdit>

// KDE
#include <KNS3/DownloadDialog>

// Fcitx
#include <fcitx-config/xdg.h>

Expand Down Expand Up @@ -167,7 +164,7 @@ void SkinPage::Private::SkinModel::setSkinList(const QStringList& list)
endRemoveRows();

QStringList sortedList = list;
qSort(sortedList);
std::sort(sortedList.begin(), sortedList.end());

Q_FOREACH(const QString & im, sortedList) {
beginInsertRows(QModelIndex(), m_skins.size(), m_skins.size());
Expand Down Expand Up @@ -254,8 +251,8 @@ QPixmap SkinPage::Private::SkinModel::drawSkinPreview(const QString& path)
else
resizeHeight = skin.inputbar.iOutputPos;
for (int i = 0; i < 2; i++) {
resizeWidth += metrics.width(numberStr[i]);
resizeWidth += metrics.width(candStr[i]);
resizeWidth += metrics.horizontalAdvance(numberStr[i]);
resizeWidth += metrics.horizontalAdvance(candStr[i]);
};
int totalWidth = marginLeft + marginRight + resizeWidth;
int totalHeight = marginTop + marginBottom + resizeHeight;
Expand Down Expand Up @@ -286,23 +283,23 @@ QPixmap SkinPage::Private::SkinModel::drawSkinPreview(const QString& path)
QColor otherColor = ConvertColor(skin.inputbar.otherColor);

textPainter.setPen(inputColor);
textPainter.drawText(marginLeft, inputPos, metrics.width(inputExample), fontHeight, Qt::AlignVCenter, inputExample);
textPainter.drawText(marginLeft, inputPos, metrics.horizontalAdvance(inputExample), fontHeight, Qt::AlignVCenter, inputExample);

// Draw candidate number:
textPainter.setPen(indexColor);
for (int i = 0; i < 2; i++) {
textPainter.drawText(offset, outputPos, metrics.width(numberStr[i]), fontHeight, Qt::AlignVCenter, numberStr[i]);
offset = offset + metrics.width(numberStr[i]) + metrics.width(candStr[i]) + metrics.width(spaceStr);
textPainter.drawText(offset, outputPos, metrics.horizontalAdvance(numberStr[i]), fontHeight, Qt::AlignVCenter, numberStr[i]);
offset = offset + metrics.horizontalAdvance(numberStr[i]) + metrics.horizontalAdvance(candStr[i]) + metrics.horizontalAdvance(spaceStr);
}

offset = marginLeft + metrics.width(numberStr[0]);
offset = marginLeft + metrics.horizontalAdvance(numberStr[0]);

textPainter.setPen(firstCandColor);
textPainter.drawText(offset, outputPos, metrics.width(candStr[0]), fontHeight, Qt::AlignVCenter, candStr[0]);
offset = offset + metrics.width(candStr[0]) + metrics.width(spaceStr) + metrics.width(numberStr[1]);
textPainter.drawText(offset, outputPos, metrics.horizontalAdvance(candStr[0]), fontHeight, Qt::AlignVCenter, candStr[0]);
offset = offset + metrics.horizontalAdvance(candStr[0]) + metrics.horizontalAdvance(spaceStr) + metrics.horizontalAdvance(numberStr[1]);

textPainter.setPen(otherColor);
textPainter.drawText(offset, outputPos, metrics.width(candStr[1]), fontHeight, Qt::AlignVCenter, candStr[1]);
textPainter.drawText(offset, outputPos, metrics.horizontalAdvance(candStr[1]), fontHeight, Qt::AlignVCenter, candStr[1]);

textPainter.end();

Expand Down Expand Up @@ -388,7 +385,7 @@ QPixmap SkinPage::Private::SkinModel::drawSkinPreview(const QString& path)
QFont inputFont(qApp->font());
QFontMetrics fm(inputFont);
QString errmsg = i18n("Skin %1 Cannot be loaded").arg(skinName);
int w = fm.width(errmsg);
int w = fm.horizontalAdvance(errmsg);
QPixmap destPixmap(w, fm.height());
destPixmap.fill(Qt::transparent);

Expand Down Expand Up @@ -704,7 +701,7 @@ void SkinPage::Private::load()
delete m_subConfig;

m_subConfig = m_parser.getSubConfig("Skin");
skinModel->setSkinList(m_subConfig->fileList().toList());
skinModel->setSkinList(m_subConfig->fileList().values());

QString skinName = skinField->text();

Expand Down Expand Up @@ -824,7 +821,6 @@ SkinPage::SkinPage(Module* module, QWidget* parent):

{
m_ui->setupUi(this);
m_ui->installSkinButton->setIcon(QIcon::fromTheme("get-hot-new-stuff"));

d->configureSkinButton = m_ui->configureSkinButton;
d->deleteSkinButton = m_ui->deleteSkinButton;
Expand All @@ -836,7 +832,6 @@ SkinPage::SkinPage(Module* module, QWidget* parent):
d->skinView->setItemDelegate(d->skinDelegate);
d->module = module;

connect(m_ui->installSkinButton, SIGNAL(clicked()), this, SLOT(installButtonClicked()));
connect(d->deleteSkinButton, SIGNAL(clicked(bool)), d, SLOT(deleteSkin()));
connect(d->configureSkinButton, SIGNAL(clicked(bool)), d, SLOT(configureSkin()));
connect(d->skinView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), d, SLOT(currentSkinChanged()));
Expand Down Expand Up @@ -873,15 +868,4 @@ void SkinPage::setSkinField(QLineEdit* lineEdit)
}
}

void SkinPage::installButtonClicked()
{
QPointer<KNS3::DownloadDialog> dialog(new KNS3::DownloadDialog("fcitx-skin.knsrc"));
dialog->exec();
foreach(const KNS3::Entry & e, dialog->changedEntries()) {
qDebug() << "Changed Entry: " << e.name();
}
delete dialog;
load();
}

}
2 changes: 0 additions & 2 deletions src/skinpage.h
Expand Up @@ -44,8 +44,6 @@ public Q_SLOTS:
void save();
Q_SIGNALS:
void changed();
protected Q_SLOTS:
void installButtonClicked();
private:
class Private;
Module* m_module;
Expand Down
7 changes: 0 additions & 7 deletions src/skinpage.ui
Expand Up @@ -52,13 +52,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="installSkinButton">
<property name="text">
<string>Get New &amp;Skin...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down

0 comments on commit ac28b39

Please sign in to comment.