diff --git a/kcms/dateandtime/dateandtime.ui b/kcms/dateandtime/dateandtime.ui
index 1a2a30893..291e20237 100644
--- a/kcms/dateandtime/dateandtime.ui
+++ b/kcms/dateandtime/dateandtime.ui
@@ -1,232 +1,232 @@
Davide Bettio <davide.bettio@kdemail.net>
DateAndTime
0
0
613
463
-
0
Date and Time
-
-
Set date and time &automatically
-
Qt::Horizontal
QSizePolicy::Fixed
13
21
-
&Time server:
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
timeServerList
-
0
0
-
-
-
true
Here you can change the system date's day of the month, month and year.
-
true
0
0
-
Qt::Vertical
20
40
Time Zone
-
To change the local time zone, select your area from the list below.
-
Qt::Vertical
QSizePolicy::Fixed
20
5
-
Current local time zone:
-
true
- Search
+ Search...
-
K4TimeZoneWidget
QTreeWidget
KDatePicker
QFrame
KTreeWidgetSearchLine
QLineEdit
KSeparator
QFrame
setDateTimeAuto
toggled(bool)
cal
setDisabled(bool)
94
62
94
143
setDateTimeAuto
toggled(bool)
timeBox
setDisabled(bool)
421
54
495
213
diff --git a/kcms/kfontinst/kcmfontinst/FontFilter.cpp b/kcms/kfontinst/kcmfontinst/FontFilter.cpp
index 03d0fc55e..b29c9da52 100644
--- a/kcms/kfontinst/kcmfontinst/FontFilter.cpp
+++ b/kcms/kfontinst/kcmfontinst/FontFilter.cpp
@@ -1,395 +1,395 @@
/*
* KFontInst - KDE Font Installer
*
* Copyright 2003-2007 Craig Drummond
*
* ----
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "FontFilter.h"
#include "FontFilterProxyStyle.h"
#include "FontList.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace KFI
{
static const int constArrowPad(5);
static void deselectCurrent(QActionGroup *act)
{
QAction *prev(act->checkedAction());
if(prev)
prev->setChecked(false);
}
static void deselectCurrent(KSelectAction *act)
{
deselectCurrent(act->selectableActionGroup());
}
// FIXME: Go back to using StyleSheets instead of a proxy style
// once Qt has been fixed not to mess with widget font when
// using StyleSheets
class CFontFilterStyle : public CFontFilterProxyStyle
{
public:
CFontFilterStyle(CFontFilter *parent, int ol) : CFontFilterProxyStyle(parent), overlap(ol) {}
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override;
int overlap;
};
QRect CFontFilterStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
{
if (SE_LineEditContents==element)
{
QRect rect(style()->subElementRect(SE_LineEditContents, option, widget));
return rect.adjusted(overlap, 0, -overlap, 0);
}
return CFontFilterProxyStyle::subElementRect(element, option, widget);
}
struct SortAction
{
SortAction(QAction *a) : action(a) { }
bool operator<(const SortAction &o) const { return action->text().localeAwareCompare(o.action->text())<0; }
QAction *action;
};
static void sortActions(KSelectAction *group)
{
if(group->actions().count()>1)
{
QList actions=group->actions();
QList::ConstIterator it(actions.constBegin()),
end(actions.constEnd());
QList sorted;
for(; it!=end; ++it)
{
sorted.append(SortAction(*it));
group->removeAction(*it);
}
qSort(sorted);
QList::ConstIterator s(sorted.constBegin()),
sEnd(sorted.constEnd());
for(; s!=sEnd; ++s)
group->addAction((*s).action);
}
}
CFontFilter::CFontFilter(QWidget *parent)
: KLineEdit(parent)
{
setClearButtonShown(true);
setTrapReturnKey(true);
itsMenuButton = new QLabel(this);
itsMenuButton->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
itsMenuButton->setCursor(Qt::ArrowCursor);
itsMenuButton->setToolTip(i18n("Set Criteria"));
itsMenu=new QMenu(this);
itsPixmaps[CRIT_FAMILY]=SmallIcon("draw-text");
itsPixmaps[CRIT_STYLE]=SmallIcon("format-text-bold");
itsPixmaps[CRIT_FOUNDRY]=SmallIcon("user-identity");
itsPixmaps[CRIT_FONTCONFIG]=SmallIcon("system-search");
itsPixmaps[CRIT_FILETYPE]=SmallIcon("preferences-desktop-font-installer");
itsPixmaps[CRIT_FILENAME]=SmallIcon("application-x-font-type1");
itsPixmaps[CRIT_LOCATION]=SmallIcon("folder");
itsPixmaps[CRIT_WS]=SmallIcon("character-set");
itsActionGroup=new QActionGroup(this);
addAction(CRIT_FAMILY, i18n("Family"), true);
addAction(CRIT_STYLE, i18n("Style"), false);
KSelectAction *foundryMenu=new KSelectAction(QIcon(itsPixmaps[CRIT_FOUNDRY]), i18n("Foundry"), this);
itsActions[CRIT_FOUNDRY]=foundryMenu;
itsMenu->addAction(itsActions[CRIT_FOUNDRY]);
foundryMenu->setData((int)CRIT_FOUNDRY);
foundryMenu->setVisible(false);
connect(foundryMenu, SIGNAL(triggered(QString)), SLOT(foundryChanged(QString)));
addAction(CRIT_FONTCONFIG, i18n("FontConfig Match"), false);
KSelectAction *ftMenu=new KSelectAction(QIcon(itsPixmaps[CRIT_FILETYPE]), i18n("File Type"), this);
itsActions[CRIT_FILETYPE]=ftMenu;
itsMenu->addAction(itsActions[CRIT_FILETYPE]);
ftMenu->setData((int)CRIT_FILETYPE);
QStringList::ConstIterator it(CFontList::fontMimeTypes.constBegin()),
end(CFontList::fontMimeTypes.constEnd());
QMimeDatabase db;
for(; it!=end; ++it)
if((*it)!="application/vnd.kde.fontspackage")
{
QMimeType mime = db.mimeTypeForName(*it);
KToggleAction *act=new KToggleAction(QIcon::fromTheme(mime.iconName()), mime.comment(), this);
ftMenu->addAction(act);
act->setChecked(false);
QStringList mimes;
foreach (QString pattern, mime.globPatterns())
mimes.append(pattern.remove(QStringLiteral("*.")));
act->setData(mimes);
}
sortActions(ftMenu);
connect(ftMenu, SIGNAL(triggered(QString)), SLOT(ftChanged(QString)));
itsCurrentFileTypes.clear();
addAction(CRIT_FILENAME, i18n("File Name"), false);
addAction(CRIT_LOCATION, i18n("File Location"), false);
KSelectAction *wsMenu=new KSelectAction(QIcon(itsPixmaps[CRIT_WS]), i18n("Writing System"), this);
itsActions[CRIT_WS]=wsMenu;
itsMenu->addAction(itsActions[CRIT_WS]);
wsMenu->setData((int)CRIT_WS);
itsCurrentWs=QFontDatabase::Any;
for(int i=QFontDatabase::Latin; iaddAction(wsAct);
wsAct->setChecked(false);
wsAct->setData(i);
}
sortActions(wsMenu);
connect(wsMenu, SIGNAL(triggered(QString)), SLOT(wsChanged(QString)));
setCriteria(CRIT_FAMILY);
setStyle(new CFontFilterStyle(this, itsMenuButton->width()));
}
void CFontFilter::setFoundries(const QSet ¤tFoundries)
{
QAction *act(((KSelectAction *)itsActions[CRIT_FOUNDRY])->currentAction());
QString prev(act && act->isChecked() ? act->text() : QString());
bool changed(false);
QList prevFoundries(((KSelectAction *)itsActions[CRIT_FOUNDRY])->actions());
QList::ConstIterator fIt(prevFoundries.constBegin()),
fEnd(prevFoundries.constEnd());
QSet foundries(currentFoundries);
// Determine which of 'foundries' are new ones, and which old ones need to be removed...
for(; fIt!=fEnd; ++fIt)
{
if(foundries.contains((*fIt)->text()))
foundries.remove((*fIt)->text());
else
{
((KSelectAction *)itsActions[CRIT_FOUNDRY])->removeAction(*fIt);
(*fIt)->deleteLater();
changed=true;
}
}
if(!foundries.isEmpty())
{
// Add foundries to menu - replacing '&' with '&&', as '&' is taken to be
// a shortcut!
QSet::ConstIterator it(foundries.begin()),
end(foundries.end());
for(; it!=end; ++it)
{
QString foundry(*it);
foundry.replace("&", "&&");
((KSelectAction *)itsActions[CRIT_FOUNDRY])->addAction(foundry);
}
changed=true;
}
if(changed)
{
sortActions((KSelectAction *)itsActions[CRIT_FOUNDRY]);
if(!prev.isEmpty())
{
act=((KSelectAction *)itsActions[CRIT_FOUNDRY])->action(prev);
if(act)
((KSelectAction *)itsActions[CRIT_FOUNDRY])->setCurrentAction(act);
else
((KSelectAction *)itsActions[CRIT_FOUNDRY])->setCurrentItem(0);
}
itsActions[CRIT_FOUNDRY]->setVisible(((KSelectAction *)itsActions[CRIT_FOUNDRY])->actions().count());
}
}
QSize CFontFilter::sizeHint() const
{
return QSize(fontMetrics().width(placeholderText())+56, KLineEdit::sizeHint().height());
}
void CFontFilter::filterChanged()
{
QAction *act(itsActionGroup->checkedAction());
if(act)
{
ECriteria crit((ECriteria)act->data().toInt());
if(itsCurrentCriteria!=crit)
{
deselectCurrent((KSelectAction *)itsActions[CRIT_FOUNDRY]);
deselectCurrent((KSelectAction *)itsActions[CRIT_FILETYPE]);
deselectCurrent((KSelectAction *)itsActions[CRIT_WS]);
setText(QString());
itsCurrentWs=QFontDatabase::Any;
itsCurrentFileTypes.clear();
setCriteria(crit);
- setPlaceholderText(i18n("Type here to filter on %1", act->text().toLower()));
+ setPlaceholderText(i18n("Filter by %1...", act->text().toLower()));
setReadOnly(false);
}
}
}
void CFontFilter::ftChanged(const QString &ft)
{
deselectCurrent((KSelectAction *)itsActions[CRIT_FOUNDRY]);
deselectCurrent((KSelectAction *)itsActions[CRIT_WS]);
deselectCurrent(itsActionGroup);
QAction *act(((KSelectAction *)itsActions[CRIT_FILETYPE])->currentAction());
if(act)
itsCurrentFileTypes=act->data().toStringList();
itsCurrentCriteria=CRIT_FILETYPE;
setReadOnly(true);
setCriteria(itsCurrentCriteria);
setText(ft);
setPlaceholderText(text());
}
void CFontFilter::wsChanged(const QString &writingSystemName)
{
deselectCurrent((KSelectAction *)itsActions[CRIT_FOUNDRY]);
deselectCurrent((KSelectAction *)itsActions[CRIT_FILETYPE]);
deselectCurrent(itsActionGroup);
QAction *act(((KSelectAction *)itsActions[CRIT_WS])->currentAction());
if(act)
itsCurrentWs=(QFontDatabase::WritingSystem)act->data().toInt();
itsCurrentCriteria=CRIT_WS;
setReadOnly(true);
setCriteria(itsCurrentCriteria);
setText(writingSystemName);
setPlaceholderText(text());
}
void CFontFilter::foundryChanged(const QString &foundry)
{
deselectCurrent((KSelectAction *)itsActions[CRIT_WS]);
deselectCurrent((KSelectAction *)itsActions[CRIT_FILETYPE]);
deselectCurrent(itsActionGroup);
itsCurrentCriteria=CRIT_FOUNDRY;
setReadOnly(true);
setText(foundry);
setPlaceholderText(text());
setCriteria(itsCurrentCriteria);
}
void CFontFilter::addAction(ECriteria crit, const QString &text, bool on)
{
itsActions[crit]=new KToggleAction(QIcon(itsPixmaps[crit]),
text, this);
itsMenu->addAction(itsActions[crit]);
itsActionGroup->addAction(itsActions[crit]);
itsActions[crit]->setData((int)crit);
itsActions[crit]->setChecked(on);
if(on)
setPlaceholderText(i18n("Type here to filter on %1", text.toLower()));
connect(itsActions[crit], SIGNAL(toggled(bool)), SLOT(filterChanged()));
}
void CFontFilter::resizeEvent(QResizeEvent *ev)
{
KLineEdit::resizeEvent(ev);
int frameWidth(style()->pixelMetric(QStyle::PM_DefaultFrameWidth)),
y((height()-itsMenuButton->height())/2);
if (qApp->isLeftToRight())
itsMenuButton->move(frameWidth + 2, y);
else
itsMenuButton->move(size().width() - frameWidth - itsMenuButton->width() - 2, y);
}
void CFontFilter::mousePressEvent(QMouseEvent *ev)
{
if(Qt::LeftButton==ev->button() && itsMenuButton->underMouse())
itsMenu->popup(mapToGlobal(QPoint(0, height())), nullptr);
else
KLineEdit::mousePressEvent(ev);
}
void CFontFilter::setCriteria(ECriteria crit)
{
QPixmap arrowmap(itsPixmaps[crit].width()+constArrowPad, itsPixmaps[crit].height());
QColor bgnd(palette().color(QPalette::Active, QPalette::Base));
bgnd.setAlphaF(0.0);
arrowmap.fill(bgnd);
QPainter p(&arrowmap);
p.drawPixmap(0, 0, itsPixmaps[crit]);
QStyleOption opt;
opt.state = QStyle::State_Enabled;
opt.rect = QRect(arrowmap.width()-(constArrowPad+1), arrowmap.height()-(constArrowPad+1), constArrowPad, constArrowPad);
style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &opt, &p, itsMenuButton);
p.end();
itsMenuButton->setPixmap(arrowmap);
itsMenuButton->resize(arrowmap.width(), arrowmap.height());
itsCurrentCriteria=crit;
emit criteriaChanged(crit, ((qulonglong)1) << (int)itsCurrentWs, itsCurrentFileTypes);
}
}