mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22:52 +00:00
kdeplasma-addons: move notes applet to kde-workspace
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
2814b80306
commit
5aeb2fbe2e
10 changed files with 0 additions and 1803 deletions
|
@ -8,7 +8,6 @@ add_subdirectory(kolourpicker)
|
|||
add_subdirectory(konsoleprofiles)
|
||||
add_subdirectory(life)
|
||||
add_subdirectory(magnifique)
|
||||
add_subdirectory(notes)
|
||||
add_subdirectory(spellcheck)
|
||||
add_subdirectory(timer)
|
||||
add_subdirectory(eyes)
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
project(plasma-notes)
|
||||
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
)
|
||||
|
||||
set(notes_SRCS notes.cpp textedit.cpp config.ui)
|
||||
|
||||
kde4_add_plugin(plasma_applet_notes ${notes_SRCS})
|
||||
target_link_libraries(plasma_applet_notes
|
||||
KDE4::plasma KDE4::kio
|
||||
)
|
||||
install(
|
||||
TARGETS plasma_applet_notes
|
||||
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install(
|
||||
FILES plasma-notes-default.desktop
|
||||
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install(
|
||||
FILES notes.svgz
|
||||
DESTINATION ${KDE4_DATA_INSTALL_DIR}/desktoptheme/default/widgets/)
|
|
@ -1,3 +0,0 @@
|
|||
#! /usr/bin/env bash
|
||||
$EXTRACTRC *.ui >> rc.cpp
|
||||
$XGETTEXT *.cpp -o $podir/plasma_applet_notes.pot
|
|
@ -1,522 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>config</class>
|
||||
<widget class="QWidget" name="config">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>417</width>
|
||||
<height>409</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="fontGroupLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="fontStyleLabel">
|
||||
<property name="text">
|
||||
<string>Style:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>fontStyleComboBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QFontComboBox" name="fontStyleComboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="fontBoldCheckBox">
|
||||
<property name="text">
|
||||
<string>&Bold</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="fontItalicCheckBox">
|
||||
<property name="text">
|
||||
<string>&Italic</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="fontSizeLabel">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="autoFont">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Scale font size by:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KIntSpinBox" name="autoFontPercent">
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="customFont">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use custom font size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KIntSpinBox" name="customFontSizeSpinBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="fontColorLabel">
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QRadioButton" name="useThemeColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use theme color</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="useCustomColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use custom color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorButton" name="textColorButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLabel" name="fontBackgroundColorLabel">
|
||||
<property name="text">
|
||||
<string>Active line highlight color:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2">
|
||||
<widget class="QRadioButton" name="useNoColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use no color</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="useCustomBackgroundColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use custom color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorButton" name="textBackgroundColorButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>13</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="themeGroupLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<widget class="QLabel" name="notesColorLabel">
|
||||
<property name="text">
|
||||
<string>Notes color:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>notesColorComboBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="KComboBox" name="notesColorComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>13</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="14" column="0" colspan="2">
|
||||
<widget class="QLabel" name="spellCheckLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Spell Check</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="1">
|
||||
<widget class="QLabel" name="checkSpellingLabel">
|
||||
<property name="text">
|
||||
<string>Enable spell check:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkSpelling</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkSpelling">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="16" column="1" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>9</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KIntSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>knuminput.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>kcombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>kcolorbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>customFont</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>customFontSizeSpinBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>407</x>
|
||||
<y>195</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>494</x>
|
||||
<y>200</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>autoFont</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>autoFontPercent</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>381</x>
|
||||
<y>159</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>468</x>
|
||||
<y>164</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>useCustomColor</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>textColorButton</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>367</x>
|
||||
<y>270</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>472</x>
|
||||
<y>272</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>useCustomBackgroundColor</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>textBackgroundColorButton</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>348</x>
|
||||
<y>337</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>437</x>
|
||||
<y>343</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -1,720 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2007 Lukas Kropatschek <lukas.krop@kdemail.net> *
|
||||
* Copyright (C) 2008 Sebastian Kügler <sebas@kde.org> *
|
||||
* Copyright (C) 2008 Davide Bettio <davide.bettio@kdemail.net> *
|
||||
* *
|
||||
* 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; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#include "notes.h"
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QTextStream>
|
||||
|
||||
#include <QtGui/QGraphicsGridLayout>
|
||||
#include <QtGui/QGraphicsLinearLayout>
|
||||
#include <QtGui/qgraphicsitem.h>
|
||||
#include <QtGui/QScrollBar>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QParallelAnimationGroup>
|
||||
|
||||
#include <KConfigDialog>
|
||||
#include <KConfigGroup>
|
||||
#include <KGlobalSettings>
|
||||
#include <KFileDialog>
|
||||
#include <KMessageBox>
|
||||
#include <KIcon>
|
||||
#include <KPushButton>
|
||||
#include <KStandardAction>
|
||||
#include <KAction>
|
||||
#include <KColorUtils>
|
||||
|
||||
#include <Plasma/Animator>
|
||||
#include <Plasma/Animation>
|
||||
#include <Plasma/PushButton>
|
||||
#include <Plasma/Theme>
|
||||
|
||||
#include "textedit.h"
|
||||
|
||||
QString defaultBackgroundColor()
|
||||
{
|
||||
// returns a suitable background color according to the plasma theme's TextColor
|
||||
return KColorUtils::luma(Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor)) > qreal(0.4) ? "black" : "yellow";
|
||||
}
|
||||
|
||||
class TopWidget : public QGraphicsWidget
|
||||
{
|
||||
public:
|
||||
TopWidget(QGraphicsWidget *parent)
|
||||
: QGraphicsWidget(parent),
|
||||
m_notesTheme(new Plasma::Svg(this)),
|
||||
m_color(defaultBackgroundColor() + "-notes")
|
||||
{
|
||||
m_notesTheme->setImagePath("widgets/notes");
|
||||
m_notesTheme->setContainsMultipleImages(false);
|
||||
}
|
||||
|
||||
void paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
m_notesTheme->resize(geometry().size());
|
||||
m_notesTheme->paint(p, contentsRect(), m_color);
|
||||
}
|
||||
|
||||
bool hasColor(const QString &color) const
|
||||
{
|
||||
return m_notesTheme->hasElement(color + "-notes");
|
||||
}
|
||||
|
||||
QString color() const
|
||||
{
|
||||
return QString(m_color).remove("-notes");
|
||||
}
|
||||
|
||||
void setColor(QString color)
|
||||
{
|
||||
color.remove("-notes");
|
||||
if (hasColor(color)) {
|
||||
m_color = color + "-notes";
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Plasma::Svg *m_notesTheme;
|
||||
QString m_color;
|
||||
};
|
||||
|
||||
Notes::Notes(QObject *parent, const QVariantList &args)
|
||||
: Plasma::PopupApplet(parent, args),
|
||||
m_wheelFontAdjustment(0),
|
||||
m_layout(0),
|
||||
m_textEdit(0)
|
||||
{
|
||||
setStatus(Plasma::AcceptingInputStatus);
|
||||
setAspectRatioMode(Plasma::IgnoreAspectRatio);
|
||||
setHasConfigurationInterface(true);
|
||||
setAcceptDrops(true);
|
||||
setAcceptHoverEvents(true);
|
||||
setBackgroundHints(Plasma::Applet::NoBackground);
|
||||
m_saveTimer.setSingleShot(true);
|
||||
connect(&m_saveTimer, SIGNAL(timeout()), this, SLOT(saveNote()));
|
||||
resize(256, 256);
|
||||
|
||||
m_topWidget = new TopWidget(this);
|
||||
m_layout = new QGraphicsLinearLayout(Qt::Vertical);
|
||||
m_topWidget->setLayout(m_layout);
|
||||
|
||||
m_textEdit = new Plasma::TextEdit(m_topWidget);
|
||||
m_textEdit->setMinimumSize(QSize(60, 60)); //Ensure a minimum size (height) for the textEdit
|
||||
|
||||
KTextEdit *w = m_textEdit->nativeWidget();
|
||||
m_noteEditor = new NotesTextEdit();
|
||||
m_noteEditor->setFrameShape(QFrame::NoFrame);
|
||||
m_noteEditor->viewport()->setAutoFillBackground(false);
|
||||
m_noteEditor->setWindowFlags(m_noteEditor->windowFlags() | Qt::BypassGraphicsProxyWidget);
|
||||
if (m_noteEditor->verticalScrollBar() && w->verticalScrollBar()) {
|
||||
m_noteEditor->verticalScrollBar()->setStyle(w->verticalScrollBar()->style());
|
||||
}
|
||||
//FIXME: we need a way to just add actions without changing the noteEditor widget under its feet
|
||||
m_textEdit->setNativeWidget(m_noteEditor);
|
||||
|
||||
// scrollwheel + ctrl changes font size
|
||||
m_layout->setSpacing(2); //We need a bit of spacing between the edit and the buttons
|
||||
m_layout->addItem(m_textEdit);
|
||||
|
||||
if (args.count() > 0) {
|
||||
KUrl url = KUrl(args.at(0).toString());
|
||||
QFile f(url.path());
|
||||
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
QTextStream t(&f);
|
||||
m_noteEditor->setTextOrHtml(t.readAll());
|
||||
QTimer::singleShot(1000, this, SLOT(saveNote()));
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
createTextFormatingWidgets();
|
||||
setPopupIcon("knotes");
|
||||
setGraphicsWidget(m_topWidget);
|
||||
}
|
||||
|
||||
Notes::~Notes()
|
||||
{
|
||||
saveNote();
|
||||
delete m_textEdit;
|
||||
delete m_colorMenu;
|
||||
delete m_formatMenu;
|
||||
}
|
||||
|
||||
void Notes::init()
|
||||
{
|
||||
m_colorMenu = new QMenu(i18n("Notes Color"));
|
||||
connect(m_colorMenu, SIGNAL(triggered(QAction*)), this, SLOT(changeColor(QAction*)));
|
||||
addColor("white", i18n("White"));
|
||||
addColor("black", i18n("Black"));
|
||||
addColor("red", i18n("Red"));
|
||||
addColor("orange", i18n("Orange"));
|
||||
addColor("yellow", i18n("Yellow"));
|
||||
addColor("green", i18n("Green"));
|
||||
addColor("blue", i18n("Blue"));
|
||||
addColor("pink", i18n("Pink"));
|
||||
addColor("translucent", i18n("Translucent"));
|
||||
|
||||
m_autoFont = false;
|
||||
|
||||
configChanged();
|
||||
|
||||
connect(m_noteEditor, SIGNAL(error(QString)), this, SLOT(showError(QString)));
|
||||
connect(m_noteEditor, SIGNAL(scrolledUp()), this, SLOT(increaseFontSize()));
|
||||
connect(m_noteEditor, SIGNAL(scrolledDown()), this, SLOT(decreaseFontSize()));
|
||||
connect(m_noteEditor, SIGNAL(cursorMoved()), this, SLOT(delayedSaveNote()));
|
||||
connect(m_noteEditor, SIGNAL(cursorMoved()), this, SLOT(lineChanged()));
|
||||
}
|
||||
|
||||
void Notes::configChanged()
|
||||
{
|
||||
KConfigGroup cg = config();
|
||||
m_topWidget->setColor(cg.readEntry("color", defaultBackgroundColor()));
|
||||
// color must be before setPlainText("foo")
|
||||
m_useThemeColor = cg.readEntry("useThemeColor", true);
|
||||
m_useNoColor = cg.readEntry("useNoColor", true);
|
||||
if (m_useThemeColor) {
|
||||
m_textColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
|
||||
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeChanged()));
|
||||
} else {
|
||||
m_textColor = cg.readEntry("textColor", m_textColor);
|
||||
}
|
||||
m_textBackgroundColor = cg.readEntry("textBackgroundColor", QColor(Qt::transparent));
|
||||
|
||||
m_font = cg.readEntry("font", KGlobalSettings::generalFont());
|
||||
|
||||
m_customFontSize = cg.readEntry("customFontSize", m_font.pointSize());
|
||||
m_autoFont = cg.readEntry("autoFont", false);
|
||||
m_autoFontPercent = cg.readEntry("autoFontPercent", 4);
|
||||
|
||||
m_checkSpelling = cg.readEntry("checkSpelling", false);
|
||||
m_noteEditor->setCheckSpellingEnabled(m_checkSpelling);
|
||||
|
||||
QString text = cg.readEntry("autoSaveHtml", QString());
|
||||
if (text.isEmpty()) {
|
||||
// see if the old, plain text version is still there?
|
||||
text = cg.readEntry("autoSave", QString());
|
||||
if (!text.isEmpty()) {
|
||||
m_noteEditor->setText(text);
|
||||
cg.deleteEntry("autoSave");
|
||||
saveNote();
|
||||
}
|
||||
} else {
|
||||
m_noteEditor->setHtml(text);
|
||||
}
|
||||
|
||||
//Set the font family and color, it may have changed from the outside
|
||||
QTextCursor oldCursor = m_noteEditor->textCursor();
|
||||
m_noteEditor->selectAll();
|
||||
m_textEdit->setFont(m_font);
|
||||
m_noteEditor->setTextColor(m_textColor);
|
||||
m_noteEditor->setTextCursor(oldCursor);
|
||||
|
||||
int scrollValue = cg.readEntry("scrollValue").toInt();
|
||||
if (scrollValue) {
|
||||
m_noteEditor->verticalScrollBar()->setValue(scrollValue);
|
||||
}
|
||||
|
||||
updateTextGeometry();
|
||||
|
||||
// make sure changes to the background colour take effect immediately
|
||||
update();
|
||||
}
|
||||
|
||||
void Notes::showError(const QString &message)
|
||||
{
|
||||
showMessage(KIcon("dialog-error"), message, Plasma::ButtonOk);
|
||||
}
|
||||
|
||||
/**
|
||||
* this function is called when you change the line you are editing
|
||||
* to change the background color
|
||||
*/
|
||||
void Notes::lineChanged()
|
||||
{
|
||||
//Re-set the formatting if previous text was deleted
|
||||
QTextCursor textCursor = m_noteEditor->textCursor();
|
||||
if (textCursor.atStart()) {
|
||||
QTextCharFormat fmt;
|
||||
fmt.setForeground(QBrush(m_textColor));
|
||||
fmt.setFont(m_font);
|
||||
m_noteEditor->setCurrentCharFormat(fmt);
|
||||
}
|
||||
|
||||
if (m_useNoColor) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTextEdit::ExtraSelection textxtra;
|
||||
textxtra.cursor = m_noteEditor->textCursor();
|
||||
textxtra.cursor.movePosition(QTextCursor::StartOfLine);
|
||||
textxtra.cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
|
||||
textxtra.format.setBackground(m_textBackgroundColor);
|
||||
|
||||
QList<QTextEdit::ExtraSelection> extras;
|
||||
extras << textxtra;
|
||||
m_noteEditor->setExtraSelections( extras );
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void Notes::constraintsEvent(Plasma::Constraints constraints)
|
||||
{
|
||||
//XXX why does everything break so horribly if I remove this line?
|
||||
setBackgroundHints(Plasma::Applet::NoBackground);
|
||||
if (constraints & Plasma::SizeConstraint) {
|
||||
updateTextGeometry();
|
||||
}
|
||||
|
||||
if (constraints & Plasma::FormFactorConstraint) {
|
||||
if (formFactor() == Plasma::Horizontal || formFactor() == Plasma::Vertical) {
|
||||
setAspectRatioMode(Plasma::ConstrainedSquare);
|
||||
} else {
|
||||
setAspectRatioMode(Plasma::IgnoreAspectRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Notes::updateTextGeometry()
|
||||
{
|
||||
if (m_layout) {
|
||||
//FIXME: this needs to come from the svg
|
||||
const qreal xpad = geometry().width() / 15;
|
||||
const qreal ypad = geometry().height() / 15;
|
||||
m_layout->setContentsMargins(xpad, ypad, xpad, ypad);
|
||||
m_font.setPointSize(fontSize());
|
||||
|
||||
QTextCursor oldTextCursor = m_noteEditor->textCursor();
|
||||
m_noteEditor->selectAll();
|
||||
m_noteEditor->setFontPointSize(m_font.pointSize());
|
||||
m_noteEditor->setTextCursor(oldTextCursor);
|
||||
|
||||
if (m_autoFont) {
|
||||
lineChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Notes::fontSize()
|
||||
{
|
||||
if (m_autoFont) {
|
||||
int autosize = qRound(((geometry().width() + geometry().height())/2)*m_autoFontPercent/100) + m_wheelFontAdjustment;
|
||||
return qMax(KGlobalSettings::smallestReadableFont().pointSize(), autosize);
|
||||
} else {
|
||||
return m_customFontSize + m_wheelFontAdjustment;
|
||||
}
|
||||
}
|
||||
|
||||
void Notes::increaseFontSize()
|
||||
{
|
||||
m_wheelFontAdjustment++;
|
||||
updateTextGeometry();
|
||||
}
|
||||
|
||||
void Notes::decreaseFontSize()
|
||||
{
|
||||
|
||||
if (KGlobalSettings::smallestReadableFont().pointSize() < fontSize()) {
|
||||
m_wheelFontAdjustment--;
|
||||
updateTextGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
void Notes::delayedSaveNote()
|
||||
{
|
||||
m_saveTimer.start(5000);
|
||||
}
|
||||
|
||||
void Notes::saveNote()
|
||||
{
|
||||
KConfigGroup cg = config();
|
||||
saveState(cg);
|
||||
emit configNeedsSaving();
|
||||
}
|
||||
|
||||
void Notes::saveState(KConfigGroup &cg) const
|
||||
{
|
||||
cg.writeEntry("autoSaveHtml", m_noteEditor->toHtml());
|
||||
cg.writeEntry("scrollValue", QVariant(m_noteEditor->verticalScrollBar()->value()));
|
||||
}
|
||||
|
||||
void Notes::themeChanged()
|
||||
{
|
||||
if (m_useThemeColor) {
|
||||
m_textColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
|
||||
QTextCursor oldCursor = m_noteEditor->textCursor();
|
||||
m_noteEditor->selectAll();
|
||||
m_noteEditor->setTextColor(m_textColor);
|
||||
m_noteEditor->setTextCursor(oldCursor);
|
||||
}
|
||||
KConfigGroup cg = config();
|
||||
m_topWidget->setColor(cg.readEntry("color", defaultBackgroundColor()));
|
||||
update();
|
||||
}
|
||||
|
||||
void Notes::addColor(const QString &id, const QString &colorName)
|
||||
{
|
||||
if (m_topWidget->hasColor(id)) {
|
||||
QAction *tmpAction = m_colorMenu->addAction(colorName);
|
||||
tmpAction->setProperty("color", id);
|
||||
}
|
||||
}
|
||||
|
||||
void Notes::changeColor(QAction *action)
|
||||
{
|
||||
if (!action || action->property("color").type() != QVariant::String) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_topWidget->setColor(action->property("color").toString());
|
||||
KConfigGroup cg = config();
|
||||
cg.writeEntry("color", m_topWidget->color());
|
||||
emit configNeedsSaving();
|
||||
update();
|
||||
}
|
||||
|
||||
QList<QAction *> Notes::contextualActions()
|
||||
{
|
||||
QList<QAction *> actions;
|
||||
actions.append(m_colorMenu->menuAction());
|
||||
actions.append(m_formatMenu->menuAction());
|
||||
return actions;
|
||||
}
|
||||
|
||||
void Notes::createConfigurationInterface(KConfigDialog *parent)
|
||||
{
|
||||
QWidget *widget = new QWidget(parent);
|
||||
ui.setupUi(widget);
|
||||
parent->addPage(widget, i18n("General"), "knotes");
|
||||
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
|
||||
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
|
||||
|
||||
QButtonGroup *fontSizeGroup = new QButtonGroup(widget);
|
||||
fontSizeGroup->addButton(ui.autoFont);
|
||||
fontSizeGroup->addButton(ui.customFont);
|
||||
|
||||
ui.textColorButton->setColor(m_textColor);
|
||||
ui.textBackgroundColorButton->setColor(m_textBackgroundColor);
|
||||
ui.fontStyleComboBox->setCurrentFont(m_font);
|
||||
ui.fontBoldCheckBox->setChecked(m_font.bold());
|
||||
ui.fontItalicCheckBox->setChecked(m_font.italic());
|
||||
ui.autoFont->setChecked(m_autoFont);
|
||||
ui.autoFontPercent->setEnabled(m_autoFont);
|
||||
ui.customFont->setChecked(!m_autoFont);
|
||||
ui.customFontSizeSpinBox->setEnabled(!m_autoFont);
|
||||
ui.autoFontPercent->setValue(m_autoFontPercent);
|
||||
ui.customFontSizeSpinBox->setValue(m_customFontSize);
|
||||
|
||||
QButtonGroup *FontColorGroup = new QButtonGroup(widget);
|
||||
FontColorGroup->addButton(ui.useThemeColor);
|
||||
FontColorGroup->addButton(ui.useCustomColor);
|
||||
ui.useThemeColor->setChecked(m_useThemeColor);
|
||||
ui.useCustomColor->setChecked(!m_useThemeColor);
|
||||
|
||||
QButtonGroup *BackgroundColorGroup = new QButtonGroup(widget);
|
||||
BackgroundColorGroup->addButton(ui.useNoColor);
|
||||
BackgroundColorGroup->addButton(ui.useCustomBackgroundColor);
|
||||
ui.useNoColor->setChecked(m_useNoColor);
|
||||
ui.useCustomBackgroundColor->setChecked(!m_useNoColor);
|
||||
|
||||
ui.checkSpelling->setChecked(m_checkSpelling);
|
||||
|
||||
QList<QAction *> colorActions = m_colorMenu->actions();
|
||||
const QString currentColor = m_topWidget->color();
|
||||
for (int i = 0; i < colorActions.size(); i++){
|
||||
QString text = colorActions.at(i)->text().remove('&');
|
||||
if (!text.isEmpty()){
|
||||
ui.notesColorComboBox->insertItem(i, text);
|
||||
if (colorActions.at(i)->property("color").toString() == currentColor) {
|
||||
ui.notesColorComboBox->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
connect(ui.fontStyleComboBox, SIGNAL(currentFontChanged(QFont)), parent, SLOT(settingsModified()));
|
||||
connect(ui.fontBoldCheckBox, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
||||
connect(ui.fontItalicCheckBox, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
||||
connect(ui.autoFontPercent, SIGNAL(valueChanged(int)), parent, SLOT(settingsModified()));
|
||||
connect(ui.autoFont, SIGNAL(clicked(bool)), parent, SLOT(settingsModified()));
|
||||
connect(ui.customFontSizeSpinBox, SIGNAL(valueChanged(int)), parent, SLOT(settingsModified()));
|
||||
connect(ui.textBackgroundColorButton, SIGNAL(changed(QColor)), parent, SLOT(settingsModified()));
|
||||
connect(ui.textColorButton, SIGNAL(changed(QColor)), parent, SLOT(settingsModified()));
|
||||
connect(ui.notesColorComboBox, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
|
||||
connect(ui.checkSpelling, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
||||
connect(ui.useThemeColor, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
||||
connect(ui.useCustomColor, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
||||
connect(ui.useCustomBackgroundColor, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
||||
connect(ui.useNoColor, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
||||
}
|
||||
|
||||
void Notes::configAccepted()
|
||||
{
|
||||
KConfigGroup cg = config();
|
||||
bool changed = false;
|
||||
|
||||
QFont newFont = ui.fontStyleComboBox->currentFont();
|
||||
newFont.setBold(ui.fontBoldCheckBox->isChecked());
|
||||
newFont.setItalic(ui.fontItalicCheckBox->isChecked());
|
||||
|
||||
//Apply bold and italic changes (if any) here (this is destructive formatting)
|
||||
bool boldChanged = (m_font.bold() != newFont.bold());
|
||||
bool italicChanged = (m_font.italic() != newFont.italic());
|
||||
if (boldChanged || italicChanged) {
|
||||
//Save previous selection
|
||||
QTextCursor oldCursor = m_noteEditor->textCursor();
|
||||
m_noteEditor->selectAll();
|
||||
if (boldChanged) {
|
||||
m_noteEditor->setFontWeight(newFont.weight());
|
||||
}
|
||||
if (italicChanged) {
|
||||
m_noteEditor->setFontItalic(newFont.italic());
|
||||
}
|
||||
//Restore previous selection
|
||||
m_noteEditor->setTextCursor(oldCursor);
|
||||
}
|
||||
|
||||
//Save font settings to config
|
||||
if (m_font != newFont) {
|
||||
changed = true;
|
||||
cg.writeEntry("font", newFont);
|
||||
m_font = newFont;
|
||||
|
||||
//Apply font family
|
||||
QTextCursor oldCursor = m_noteEditor->textCursor();
|
||||
m_noteEditor->selectAll();
|
||||
m_noteEditor->setFontFamily(m_font.family());
|
||||
m_noteEditor->setTextCursor(oldCursor);
|
||||
}
|
||||
|
||||
if (m_customFontSize != ui.customFontSizeSpinBox->value()) {
|
||||
changed = true;
|
||||
m_customFontSize = ui.customFontSizeSpinBox->value();
|
||||
cg.writeEntry("customFontSize", m_customFontSize);
|
||||
}
|
||||
|
||||
if (m_autoFont != ui.autoFont->isChecked()) {
|
||||
changed = true;
|
||||
m_autoFont = ui.autoFont->isChecked();
|
||||
cg.writeEntry("autoFont", m_autoFont);
|
||||
}
|
||||
|
||||
if (m_autoFontPercent != ui.autoFontPercent->value()) {
|
||||
changed = true;
|
||||
m_autoFontPercent = (ui.autoFontPercent->value());
|
||||
cg.writeEntry("autoFontPercent", m_autoFontPercent);
|
||||
}
|
||||
|
||||
disconnect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeChanged()));
|
||||
bool textColorChanged = false;
|
||||
if (m_useThemeColor != ui.useThemeColor->isChecked()) {
|
||||
changed = true;
|
||||
textColorChanged = true;
|
||||
m_useThemeColor = ui.useThemeColor->isChecked();
|
||||
cg.writeEntry("useThemeColor", m_useThemeColor);
|
||||
}
|
||||
|
||||
if (m_useThemeColor) {
|
||||
m_textColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
|
||||
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeChanged()));
|
||||
} else {
|
||||
const QColor newColor = ui.textColorButton->color();
|
||||
if (m_textColor != newColor) {
|
||||
changed = true;
|
||||
textColorChanged = true;
|
||||
m_textColor = newColor;
|
||||
cg.writeEntry("textColor", m_textColor);
|
||||
}
|
||||
}
|
||||
|
||||
if (textColorChanged) {
|
||||
QTextCursor oldCursor = m_noteEditor->textCursor();
|
||||
m_noteEditor->selectAll();
|
||||
m_noteEditor->setTextColor(m_textColor);
|
||||
m_noteEditor->setTextCursor(oldCursor);
|
||||
}
|
||||
|
||||
if (m_useNoColor != ui.useNoColor->isChecked()) {
|
||||
changed = true;
|
||||
m_useNoColor = ui.useNoColor->isChecked();
|
||||
cg.writeEntry("useNoColor", m_useNoColor);
|
||||
QTextCursor textCursor = m_noteEditor->textCursor();
|
||||
QTextEdit::ExtraSelection textxtra;
|
||||
textxtra.cursor = m_noteEditor->textCursor();
|
||||
textxtra.cursor.movePosition( QTextCursor::StartOfLine );
|
||||
textxtra.cursor.movePosition( QTextCursor::EndOfLine, QTextCursor::KeepAnchor );
|
||||
textxtra.format.setBackground( Qt::transparent );
|
||||
|
||||
QList<QTextEdit::ExtraSelection> extras;
|
||||
extras << textxtra;
|
||||
m_noteEditor->setExtraSelections( extras );
|
||||
}
|
||||
|
||||
const QColor newBackgroundColor = ui.textBackgroundColorButton->color();
|
||||
if (m_textBackgroundColor != newBackgroundColor) {
|
||||
changed = true;
|
||||
m_textBackgroundColor = newBackgroundColor;
|
||||
cg.writeEntry("textBackgroundColor", m_textBackgroundColor);
|
||||
}
|
||||
|
||||
bool spellCheck = ui.checkSpelling->isChecked();
|
||||
if (spellCheck != m_checkSpelling) {
|
||||
changed = true;
|
||||
m_checkSpelling = spellCheck;
|
||||
cg.writeEntry("checkSpelling", m_checkSpelling);
|
||||
m_noteEditor->setCheckSpellingEnabled(m_checkSpelling);
|
||||
}
|
||||
|
||||
QList<QAction *> colorActions = m_colorMenu->actions();
|
||||
QAction *colorAction = colorActions.value(ui.notesColorComboBox->currentIndex());
|
||||
if (colorAction) {
|
||||
const QString tmpColor = colorAction->property("color").toString();
|
||||
if (tmpColor != m_topWidget->color()){
|
||||
m_topWidget->setColor(tmpColor);
|
||||
cg.writeEntry("color", m_topWidget->color());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
updateTextGeometry();
|
||||
update();
|
||||
emit configNeedsSaving();
|
||||
}
|
||||
}
|
||||
|
||||
void Notes::createTextFormatingWidgets()
|
||||
{
|
||||
m_formatMenu = new QMenu(i18n("Formatting"));
|
||||
m_noteEditor->setFormatMenu(m_formatMenu);
|
||||
QAction *actionBold = m_formatMenu->addAction(KIcon("format-text-bold"), i18n("Bold"));
|
||||
QAction *actionItalic = m_formatMenu->addAction(KIcon("format-text-italic"),i18n("Italic"));
|
||||
QAction *actionUnderline = m_formatMenu->addAction(KIcon("format-text-underline"), i18n("Underline"));
|
||||
QAction *actionStrikeThrough = m_formatMenu->addAction(KIcon("format-text-strikethrough"), i18n("StrikeOut"));
|
||||
QAction *actionCenter = m_formatMenu->addAction(KIcon("format-justify-center"), i18n("Justify center"));
|
||||
QAction *actionFill = m_formatMenu->addAction(KIcon("format-justify-fill"), i18n("Justify"));
|
||||
connect(actionItalic, SIGNAL(triggered()), m_noteEditor, SLOT(italic()));
|
||||
connect(actionBold, SIGNAL(triggered()), m_noteEditor, SLOT(bold()));
|
||||
connect(actionUnderline, SIGNAL(triggered()), m_noteEditor, SLOT(underline()));
|
||||
connect(actionStrikeThrough, SIGNAL(triggered()), m_noteEditor, SLOT(strikeOut()));
|
||||
connect(actionCenter, SIGNAL(triggered()), m_noteEditor, SLOT(justifyCenter()));
|
||||
connect(actionFill, SIGNAL(triggered()), m_noteEditor, SLOT(justifyFill()));
|
||||
connect(actionItalic, SIGNAL(triggered()), this, SLOT(updateOptions()));
|
||||
connect(actionBold, SIGNAL(triggered()), this, SLOT(updateOptions()));
|
||||
connect(actionUnderline, SIGNAL(triggered()), this, SLOT(updateOptions()));
|
||||
connect(actionStrikeThrough, SIGNAL(triggered()), this, SLOT(updateOptions()));
|
||||
connect(actionCenter, SIGNAL(triggered()), this, SLOT(updateOptions()));
|
||||
connect(actionFill, SIGNAL(triggered()), this, SLOT(updateOptions()));
|
||||
|
||||
QGraphicsWidget *widget = new QGraphicsWidget(m_topWidget);
|
||||
widget->setMaximumHeight(25);
|
||||
|
||||
QGraphicsLinearLayout *buttonLayout = new QGraphicsLinearLayout(Qt::Horizontal, widget);
|
||||
buttonLayout->setSpacing(0);
|
||||
buttonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
widget->setLayout(buttonLayout);
|
||||
|
||||
m_buttonOption = new Plasma::ToolButton(widget);
|
||||
m_buttonOption->nativeWidget()->setIcon(KIcon("draw-text"));
|
||||
m_buttonOption->nativeWidget()->setCheckable(true);
|
||||
|
||||
m_buttonBold = new Plasma::ToolButton(widget);
|
||||
m_buttonBold->setAction(actionBold);
|
||||
|
||||
m_buttonItalic = new Plasma::ToolButton(widget);
|
||||
m_buttonItalic->setAction(actionItalic);
|
||||
|
||||
m_buttonUnderline = new Plasma::ToolButton(widget);
|
||||
m_buttonUnderline->setAction(actionUnderline);
|
||||
|
||||
m_buttonStrikeThrough = new Plasma::ToolButton(widget);
|
||||
m_buttonStrikeThrough->setAction(actionStrikeThrough);
|
||||
|
||||
m_buttonCenter = new Plasma::ToolButton(widget);
|
||||
m_buttonCenter->setAction(actionCenter);
|
||||
|
||||
m_buttonFill = new Plasma::ToolButton(widget);
|
||||
m_buttonFill->setAction(actionFill);
|
||||
|
||||
buttonLayout->addItem(m_buttonOption);
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addItem(m_buttonBold);
|
||||
buttonLayout->addItem(m_buttonItalic);
|
||||
buttonLayout->addItem(m_buttonUnderline);
|
||||
buttonLayout->addItem(m_buttonStrikeThrough);
|
||||
buttonLayout->addItem(m_buttonCenter);
|
||||
buttonLayout->addItem(m_buttonFill);
|
||||
buttonLayout->addStretch();
|
||||
|
||||
m_layout->addItem(widget);
|
||||
|
||||
m_buttonAnimGroup = new QParallelAnimationGroup(this);
|
||||
|
||||
for (int i = 0; i < 6; i++){
|
||||
m_buttonAnim[i] = Plasma::Animator::create(Plasma::Animator::FadeAnimation, this);
|
||||
m_buttonAnimGroup->addAnimation(m_buttonAnim[i]);
|
||||
}
|
||||
|
||||
m_buttonAnim[0]->setTargetWidget(m_buttonBold);
|
||||
m_buttonAnim[1]->setTargetWidget(m_buttonItalic);
|
||||
m_buttonAnim[2]->setTargetWidget(m_buttonUnderline);
|
||||
m_buttonAnim[3]->setTargetWidget(m_buttonStrikeThrough);
|
||||
m_buttonAnim[4]->setTargetWidget(m_buttonCenter);
|
||||
m_buttonAnim[5]->setTargetWidget(m_buttonFill);
|
||||
|
||||
showOptions(false);
|
||||
connect(m_buttonOption->nativeWidget(), SIGNAL(toggled(bool)), this, SLOT(showOptions(bool)));
|
||||
|
||||
connect(m_noteEditor, SIGNAL(cursorPositionChanged()), this, SLOT(updateOptions()));
|
||||
}
|
||||
|
||||
void Notes::showOptions(bool show)
|
||||
{
|
||||
m_buttonOption->nativeWidget()->setDown(show);
|
||||
|
||||
qreal targetOpacity = show ? 1 : 0;
|
||||
qreal startOpacity = 1 - targetOpacity;
|
||||
|
||||
for (int i = 0; i < 6; i++){
|
||||
m_buttonAnim[i]->setProperty("startOpacity", startOpacity);
|
||||
m_buttonAnim[i]->setProperty("targetOpacity", targetOpacity);
|
||||
}
|
||||
|
||||
m_buttonAnimGroup->start();
|
||||
}
|
||||
|
||||
void Notes::updateOptions()
|
||||
{
|
||||
m_buttonBold->setDown(m_noteEditor->fontWeight() == QFont::Bold);
|
||||
m_buttonItalic->setDown(m_noteEditor->fontItalic());
|
||||
m_buttonUnderline->setDown(m_noteEditor->fontUnderline());
|
||||
m_buttonStrikeThrough->setDown(m_noteEditor->currentFont().strikeOut());
|
||||
m_buttonCenter->setDown(m_noteEditor->alignment() == Qt::AlignHCenter);
|
||||
m_buttonFill->setDown(m_noteEditor->alignment() == Qt::AlignJustify);
|
||||
}
|
||||
|
||||
#include "moc_notes.cpp"
|
||||
|
||||
K_EXPORT_PLASMA_APPLET(notes, Notes)
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2007 Lukas Kropatschek <lukas.krop@kdemail.net> *
|
||||
* Copyright (C) 2008 Sebastian Kügler <sebas@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) 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; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef NOTES_HEADER
|
||||
#define NOTES_HEADER
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <Plasma/PopupApplet>
|
||||
#include <Plasma/Svg>
|
||||
#include <Plasma/TextEdit>
|
||||
#include <Plasma/ToolButton>
|
||||
|
||||
#include "ui_config.h"
|
||||
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QSizeF>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QParallelAnimationGroup>
|
||||
|
||||
class TopWidget;
|
||||
class NotesTextEdit;
|
||||
|
||||
class Notes : public Plasma::PopupApplet
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Notes(QObject *parent, const QVariantList &args);
|
||||
~Notes();
|
||||
void init();
|
||||
QList<QAction*> contextualActions();
|
||||
|
||||
public Q_SLOTS:
|
||||
void configChanged();
|
||||
void configAccepted();
|
||||
void showOptions(bool show);
|
||||
|
||||
protected:
|
||||
void constraintsEvent(Plasma::Constraints constraints);
|
||||
void createConfigurationInterface(KConfigDialog *parent);
|
||||
void saveState(KConfigGroup &cg) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void saveNote();
|
||||
void delayedSaveNote();
|
||||
void changeColor(QAction*);
|
||||
void lineChanged();
|
||||
void increaseFontSize();
|
||||
void decreaseFontSize();
|
||||
void themeChanged();
|
||||
void updateOptions();
|
||||
void showError(const QString &message);
|
||||
|
||||
private:
|
||||
void createTextFormatingWidgets();
|
||||
int fontSize();
|
||||
void updateTextGeometry();
|
||||
void addColor(const QString &id, const QString &colorName);
|
||||
|
||||
int m_autoFontPercent;
|
||||
bool m_autoFont;
|
||||
bool m_checkSpelling;
|
||||
|
||||
QTimer m_saveTimer;
|
||||
QFont m_font;
|
||||
int m_customFontSize;
|
||||
bool m_useThemeColor;
|
||||
bool m_useNoColor;
|
||||
int m_wheelFontAdjustment;
|
||||
QColor m_textColor;
|
||||
QColor m_textBackgroundColor;
|
||||
|
||||
QMenu *m_colorMenu;
|
||||
QMenu *m_formatMenu;
|
||||
|
||||
QGraphicsLinearLayout *m_layout;
|
||||
Plasma::TextEdit *m_textEdit;
|
||||
NotesTextEdit *m_noteEditor;
|
||||
Ui::config ui;
|
||||
|
||||
QSizeF m_size;
|
||||
|
||||
Plasma::ToolButton *m_buttonOption;
|
||||
Plasma::ToolButton *m_buttonBold;
|
||||
Plasma::ToolButton *m_buttonItalic;
|
||||
Plasma::ToolButton *m_buttonUnderline;
|
||||
Plasma::ToolButton *m_buttonStrikeThrough;
|
||||
Plasma::ToolButton *m_buttonCenter;
|
||||
Plasma::ToolButton *m_buttonFill;
|
||||
TopWidget *m_topWidget;
|
||||
|
||||
QParallelAnimationGroup *m_buttonAnimGroup;
|
||||
Plasma::Animation *m_buttonAnim[6];
|
||||
};
|
||||
|
||||
#endif
|
Binary file not shown.
|
@ -1,132 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Name=Notes
|
||||
Name[ar]=ملاحظات
|
||||
Name[ast]=Notes
|
||||
Name[be]=Заметкі
|
||||
Name[bs]=Bilješke
|
||||
Name[ca]=Notes
|
||||
Name[ca@valencia]=Notes
|
||||
Name[cs]=Poznámky
|
||||
Name[csb]=Nadczidczi
|
||||
Name[da]=Noter
|
||||
Name[de]=Notizen
|
||||
Name[el]=Σημειώσεις
|
||||
Name[en_GB]=Notes
|
||||
Name[eo]=Notoj
|
||||
Name[es]=Notas
|
||||
Name[et]=Märkmed
|
||||
Name[eu]=Oharrak
|
||||
Name[fi]=Muistilappu
|
||||
Name[fr]=Notes
|
||||
Name[ga]=Nótaí
|
||||
Name[gl]=Notas
|
||||
Name[he]=פתקיות
|
||||
Name[hr]=Bilješke
|
||||
Name[hu]=Feljegyzések
|
||||
Name[is]=Minnismiðar
|
||||
Name[it]=Note
|
||||
Name[ja]=メモ
|
||||
Name[kk]=Жазбалар
|
||||
Name[km]=ចំណាំ
|
||||
Name[ko]=메모
|
||||
Name[ku]=Nîşe
|
||||
Name[lt]=Užrašai
|
||||
Name[lv]=Piezīmes
|
||||
Name[mr]=नोंदी
|
||||
Name[ms]=Nota
|
||||
Name[nb]=Notater
|
||||
Name[nds]=Notizen
|
||||
Name[nl]=Notities
|
||||
Name[nn]=Notat
|
||||
Name[oc]=Nòtas
|
||||
Name[pa]=ਨੋਟਿਸ
|
||||
Name[pl]=Notatki
|
||||
Name[pt]=Notas
|
||||
Name[pt_BR]=Notas
|
||||
Name[ro]=Note
|
||||
Name[ru]=Заметки
|
||||
Name[sk]=Poznámky
|
||||
Name[sl]=Opombe
|
||||
Name[sq]=Shënime
|
||||
Name[sr]=белешке
|
||||
Name[sr@ijekavian]=биљешке
|
||||
Name[sr@ijekavianlatin]=bilješke
|
||||
Name[sr@latin]=beleške
|
||||
Name[sv]=Anteckningar
|
||||
Name[th]=บันทึกช่วยจำ
|
||||
Name[tr]=Notlar
|
||||
Name[ug]=ئىزاھ
|
||||
Name[uk]=Нотатки
|
||||
Name[wa]=Notes
|
||||
Name[x-test]=xxNotesxx
|
||||
Name[zh_CN]=便笺
|
||||
Name[zh_TW]=便條
|
||||
Comment=Desktop sticky notes
|
||||
Comment[ar]=ملاحظات لاصقة على سطح المكتب
|
||||
Comment[ast]=Notas pegaes nel escritoriu
|
||||
Comment[bs]=Ljepljive bilješke za površ
|
||||
Comment[ca]=Notes adhesives d'escriptori
|
||||
Comment[ca@valencia]=Notes adhesives d'escriptori
|
||||
Comment[cs]=Lepící poznámkové papírky na plochu
|
||||
Comment[da]=Notessedler på skrivebordet.
|
||||
Comment[de]=Klebezettel für die Arbeitsfläche
|
||||
Comment[el]=Κολλημένες σημειώσεις επιφάνειας εργασίας
|
||||
Comment[en_GB]=Desktop sticky notes
|
||||
Comment[es]=Notas adhesivas de escritorio
|
||||
Comment[et]=Töölaua märkmepaberid
|
||||
Comment[eu]=Mahaigaineko ohar itsaskorrak
|
||||
Comment[fi]=Työpöydän muistilaput
|
||||
Comment[fr]=Un note collée sur le bureau
|
||||
Comment[ga]=Nótaí greamaitheacha
|
||||
Comment[gl]=Notas no escritorio
|
||||
Comment[he]=פתקיות על שולחן העבודה
|
||||
Comment[hu]=Ragadós asztali feljegyzések
|
||||
Comment[is]=Minnismiðar á skjáborði
|
||||
Comment[it]=Note adesive del desktop
|
||||
Comment[ja]=デスクトップの付箋紙メモ
|
||||
Comment[kk]=Үстелге жапсырмалы жазбалар
|
||||
Comment[km]=ចំណាំបិទលើផ្ទៃតុ
|
||||
Comment[ko]=데스크톱 메모
|
||||
Comment[ku]=Nîşeyên mezeloqî yên Sermasê
|
||||
Comment[lt]=Darbastalio lipnūs lapeliai
|
||||
Comment[lv]=Darbvirsmas piezīmju lapiņas
|
||||
Comment[mr]=डेस्कटॉप चिकट नोंदी
|
||||
Comment[nb]=Notatlapper for skrivebordet
|
||||
Comment[nds]=Opback-Notizen för den Schriefdisch
|
||||
Comment[nl]=Sticky's op het bureaublad
|
||||
Comment[nn]=Notatlappar på skrivebordet
|
||||
Comment[pa]=ਡੈਸਕਟਾਪ ਸਟਿੱਕੀ ਨੋਟਿਸ
|
||||
Comment[pl]=Żółte karteczki na pulpicie
|
||||
Comment[pt]=Notas autocolantes do ecrã
|
||||
Comment[pt_BR]=Notas adesivas na área de trabalho
|
||||
Comment[ro]=Notițe de birou lipicioase
|
||||
Comment[ru]=Стикеры для заметок на рабочий стол
|
||||
Comment[sk]=Lepiace poznámky na plochu
|
||||
Comment[sl]=Lepljive opombe za namizje
|
||||
Comment[sr]=Лепљиве белешке за површ
|
||||
Comment[sr@ijekavian]=Љепљиве биљешке за површ
|
||||
Comment[sr@ijekavianlatin]=Ljepljive bilješke za površ
|
||||
Comment[sr@latin]=Lepljive beleške za površ
|
||||
Comment[sv]=Klisterlappar med meddelanden för skrivbordet
|
||||
Comment[th]=ปักหมุดบันทึกช่วยจำไว้บนพื้นที่ทำงาน
|
||||
Comment[tr]=Masaüstüne yapışan notlar
|
||||
Comment[uk]=Стільничні липкі нотатки
|
||||
Comment[wa]=Aclapantès notes sol scribanne
|
||||
Comment[x-test]=xxDesktop sticky notesxx
|
||||
Comment[zh_CN]=桌面 n 次贴
|
||||
Comment[zh_TW]=桌面便利貼
|
||||
Icon=knotes
|
||||
Type=Service
|
||||
|
||||
X-Plasma-DropMimeTypes=text/plain,text/richtext
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
X-KDE-Library=plasma_applet_notes
|
||||
X-KDE-PluginInfo-Author=Lukas Kropatschek
|
||||
X-KDE-PluginInfo-Email=lukas.krop@gmail.com
|
||||
X-KDE-PluginInfo-Name=plasma_applet_notes
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=
|
||||
X-KDE-PluginInfo-Category=Utilities
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
|
@ -1,202 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2007 Lukas Kropatschek <lukas.krop@kdemail.net> *
|
||||
* Copyright (C) 2008 Sebastian Kügler <sebas@kde.org> *
|
||||
* Copyright (C) 2008 Davide Bettio <davide.bettio@kdemail.net> *
|
||||
* *
|
||||
* 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; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#include "textedit.h"
|
||||
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtGui/QGraphicsGridLayout>
|
||||
#include <QtGui/qgraphicsitem.h>
|
||||
#include <QtGui/QScrollBar>
|
||||
#include <QtGui/QMenu>
|
||||
|
||||
#include <KAction>
|
||||
#include <KConfigDialog>
|
||||
#include <KConfigGroup>
|
||||
#include <KGlobalSettings>
|
||||
#include <KFileDialog>
|
||||
#include <KIcon>
|
||||
#include <KStandardAction>
|
||||
|
||||
#include <Plasma/Applet>
|
||||
|
||||
NotesTextEdit::NotesTextEdit(QWidget *parent)
|
||||
: KRichTextEdit(parent),
|
||||
m_formatMenu(0)
|
||||
{
|
||||
}
|
||||
|
||||
NotesTextEdit::~NotesTextEdit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content to file
|
||||
*/
|
||||
void NotesTextEdit::saveToFile()
|
||||
{
|
||||
QString fileName = KFileDialog::getSaveFileName();
|
||||
|
||||
if (fileName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QFile file(fileName);
|
||||
|
||||
if (!file.open(QFile::WriteOnly | QFile::Truncate)) {
|
||||
emit error(file.errorString());
|
||||
return;
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
out << toPlainText();
|
||||
file.close();
|
||||
}
|
||||
|
||||
void NotesTextEdit::setFormatMenu(QMenu *menu)
|
||||
{
|
||||
m_formatMenu = menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Customize the context menu
|
||||
*/
|
||||
void NotesTextEdit::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QMenu *popup = mousePopupMenu();
|
||||
|
||||
popup->addSeparator();
|
||||
popup->addAction(KStandardAction::saveAs(this, SLOT(saveToFile()), this));
|
||||
|
||||
if (m_formatMenu) {
|
||||
popup->addMenu(m_formatMenu);
|
||||
}
|
||||
|
||||
popup->exec(event->pos());
|
||||
delete popup;
|
||||
}
|
||||
|
||||
void NotesTextEdit::italic()
|
||||
{
|
||||
setTextItalic(!fontItalic());
|
||||
}
|
||||
|
||||
void NotesTextEdit::bold()
|
||||
{
|
||||
setTextBold(fontWeight() != 75);
|
||||
}
|
||||
|
||||
void NotesTextEdit::underline()
|
||||
{
|
||||
setTextUnderline(!fontUnderline());
|
||||
}
|
||||
|
||||
void NotesTextEdit::strikeOut()
|
||||
{
|
||||
QFont a = currentFont();
|
||||
setTextStrikeOut(!a.strikeOut());
|
||||
}
|
||||
|
||||
void NotesTextEdit::justifyCenter()
|
||||
{
|
||||
if (alignment() == Qt::AlignHCenter) {
|
||||
setAlignment(Qt::AlignLeft);
|
||||
} else {
|
||||
alignCenter();
|
||||
}
|
||||
}
|
||||
|
||||
void NotesTextEdit::justifyFill()
|
||||
{
|
||||
if (alignment() == Qt::AlignJustify) {
|
||||
setAlignment(Qt::AlignLeft);
|
||||
} else {
|
||||
alignJustify();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to mousePressEvent a signal to change the edited line's background color
|
||||
*/
|
||||
void NotesTextEdit::mousePressEvent ( QMouseEvent * event )
|
||||
{
|
||||
KTextEdit::mousePressEvent(event);
|
||||
if(event->button()== Qt::LeftButton)
|
||||
emit cursorMoved();
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as mousePressEvent
|
||||
*/
|
||||
void NotesTextEdit::keyPressEvent ( QKeyEvent * event )
|
||||
{
|
||||
KTextEdit::keyPressEvent(event);
|
||||
switch(event->key())
|
||||
{
|
||||
case Qt::Key_Left : emit cursorMoved(); break;
|
||||
case Qt::Key_Right : emit cursorMoved(); break;
|
||||
case Qt::Key_Down : emit cursorMoved(); break;
|
||||
case Qt::Key_Up : emit cursorMoved(); break;
|
||||
default:break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale text on wheel scrolling with control pressed
|
||||
*/
|
||||
void NotesTextEdit::wheelEvent ( QWheelEvent * event )
|
||||
{
|
||||
if (event->modifiers() & Qt::ControlModifier ) {
|
||||
if (event->orientation() == Qt::Horizontal) {
|
||||
return;
|
||||
} else {
|
||||
if (event->delta() > 0) {
|
||||
emit scrolledUp();
|
||||
} else {
|
||||
emit scrolledDown();
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
} else {
|
||||
KTextEdit::wheelEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to the Note a signal to prevent from leaving the note and remove line background color
|
||||
* when there is no focus on the plasmoid
|
||||
*/
|
||||
void NotesTextEdit::focusOutEvent ( QFocusEvent * event )
|
||||
{
|
||||
KTextEdit::focusOutEvent(event);
|
||||
|
||||
QTextEdit::ExtraSelection textxtra;
|
||||
textxtra.cursor = textCursor();
|
||||
textxtra.cursor.movePosition(QTextCursor::StartOfLine);
|
||||
textxtra.cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
|
||||
textxtra.format.setBackground(Qt::transparent);
|
||||
|
||||
QList<QTextEdit::ExtraSelection> extras;
|
||||
extras << textxtra;
|
||||
setExtraSelections(extras);
|
||||
}
|
||||
|
||||
#include "moc_textedit.cpp"
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2007 Lukas Kropatschek <lukas.krop@kdemail.net> *
|
||||
* Copyright (C) 2008 Sebastian Kügler <sebas@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) 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; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TEXTEDIT_H
|
||||
#define TEXTEDIT_H
|
||||
|
||||
#include <KRichTextEdit>
|
||||
|
||||
#include "ui_config.h"
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class Applet;
|
||||
} // namespace Plasma
|
||||
|
||||
/**
|
||||
* @short Notes Version von KTextEdit
|
||||
*
|
||||
* This is just a little subclass of KTextEdit which provides a customized context menu and the ability to save its content into a file
|
||||
*
|
||||
* @see QTextEdit
|
||||
* @author Björn Ruberg <bjoern@ruberg-wegener.de>
|
||||
*/
|
||||
class NotesTextEdit : public KRichTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NotesTextEdit(QWidget *parent = 0);
|
||||
~NotesTextEdit();
|
||||
|
||||
void setFormatMenu(QMenu *menu);
|
||||
|
||||
public slots:
|
||||
virtual void saveToFile();
|
||||
void italic();
|
||||
void bold();
|
||||
void underline();
|
||||
void strikeOut();
|
||||
void justifyCenter();
|
||||
void justifyFill();
|
||||
|
||||
Q_SIGNALS:
|
||||
void cursorMoved();
|
||||
void scrolledUp();
|
||||
void scrolledDown();
|
||||
void error(const QString &message);
|
||||
|
||||
protected:
|
||||
virtual void contextMenuEvent(QContextMenuEvent *e);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void focusOutEvent(QFocusEvent *event);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
private:
|
||||
QMenu *m_formatMenu;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue