Commit b0c70d4c authored by Michael Zhou's avatar Michael Zhou

Refactoring to Enable KisPaletteView to Be Used in More Widgets

KisPaletteView was in kritaui, which depends on kritawidgets. There are also several widgets in kritawidgets that have their own implementation for GUI of a palette. This revision moves KisPaletteView into kritawidgets so that these widgets can use it. This way, in future modification in the palette (or the color set), fewer work would be needed.

The next step is to modify these widgets so that they use KisPaletteView instead of their own implementations.

The following changes are made:

+ KisPaletteView, KisPaletteModel and KisPaletteDelegate are now in kritawidgets

+ KisDlgInternalColorSelector and the multiple classes used by it are now in kritawidgets, except for KisScreenColorPicker, which is still in kritaui. A dependency inversion is used to enable KisDlgInternalColorSelector to use it.

+ KisColorsetSelector is now inside kritawidgets

+ KisConfigNotifier in now in kritaglobal

+ KisColorButton and KisColorInput are now in kritawidgets

+ KisPopupButton is now in kritawidgets

https://phabricator.kde.org/D13750
parents 439ea1d8 a8ca9897
......@@ -9,31 +9,45 @@ to reproduce AppImage-only bugs in Krita.
## Prerequisites
Firstly we need to download deps and Krita source tree. These steps are not
Firstly make sure you have Docker installed
```bash
sudo apt install docker docker.io
```
Then you need to download deps and Krita source tree. These steps are not
included into the *Dockerfile* to save internal bandwidth (most Krita
developers already have al least one clone of Krita source tree).
```bash
# create directory structure for container control directory
mkdir -p krita-master/persistent
cd krita-master
# copy/chechout Krita sources to 'persistent/krita'
cp -r /path/to/sources/krita ./persistent/krita
# initialize control scripts and the Dockerfile
./persistent/krita/build-tools/docker/bin/bootstrap-root.sh
# download the deps archive
./bin/bootstrap-deps.sh
# mount/copy/chechout Krita sources to 'persistent/krita'
mkdir -p persistent/krita
sudo mount --bind ../../ ./persistent/krita
```
## Build the docker image and run the container
```bash
./bin/build_image krita-deps
./bin/run_container krita-deps krita-build
./bin/run_container krita-deps krita-master
```
## Enter the container and build Krita
```bash
# enter the docker container
./bin/enter_container krita-build
# enter the docker container (the name will be
# fetched automatically from '.container_name' file)
./bin/enter
# ... now your are inside the container with all the deps prepared ...
......@@ -49,27 +63,20 @@ krita
## Extra developer tools
If you want to develop Krita, you might want to install at least some
developer tools into the container, e.g. GDB, Valgring, ccmake and QtCreator.
To do that, execute the following from yout **host** console:
To install QtCreator, enter container and start the installer, downloaded while
fetching dependencies. Make sure you install it into '~/qtcreator' directory
without any version suffixes, then you will be able to use the script below:
```bash
sudo docker exec -ti -u root krita-build apt install gdb
sudo docker exec -ti -u root krita-build apt install valgrind
sudo docker exec -ti -u root krita-build apt install cmake-curses-gui
# inside the container
cd ~/persistent
wget http://master.qt.io/archive/online_installers/3.0/qt-unified-linux-x64-3.0.4-online.run
./qt-unified-linux-x64-3.0.4-online.run
# when going through the setup wizard select not to install any
# extra Qt libraries, install QtCreator only!
./persistent/qt-creator-opensource-linux-x86_64-4.6.2.run
```
# to start QtCreator without the conflicts to with Krita's Qt paths, type
# in your **host** console:
sudo docker exec -ti krita-build /home/appimage//Qt/Tools/QtCreator/bin/qtcreator
To start QtCreator:
```bash
# from the host
./bin/qtcreator
```
## Stopping the container and cleaning up
......@@ -79,14 +86,18 @@ all the currently running processes are killed (just ensure you logout from all
terminals before stopping).
```bash
sudo docker stop krita-build
# stop the container
./bin/stop
# start the container
./bin/start
```
If you don't need your container/image anymore, you can delete them from the docker
```bash
# remove the container
sudo docker rm krita-build
sudo docker rm krita-master
# remove the image
sudo docker rmi krita-deps
......
......@@ -11,3 +11,13 @@ if [ ! -f ./persistent/krita-appimage-deps.tar ]; then
)
fi
creator_major=4.6
creator_minor=2
creator_file=qt-creator-opensource-linux-x86_64-${creator_major}.${creator_minor}.run
if [ ! -f ./persistent/${creator_file} ]; then
(
cd ./persistent/
wget http://download.qt.io/official_releases/qtcreator/${creator_major}/${creator_major}.${creator_minor}/${creator_file} || exit 1
chmod a+x ${creator_file}
)
fi
#!/bin/bash
if [ -d ./persistent/krita ]; then
for i in 'bin default-home'; do
if [ ! -d "$i" ]; then
mkdir $i
fi
done
cp persistent/krita/build-tools/docker/bin/* ./bin/
cp persistent/krita/build-tools/docker/default-home/{,.}* ./default-home/
cp persistent/krita/build-tools/docker/Dockerfile ./
cp persistent/krita/build-tools/docker/README.md ./
fi
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${DIR}/find_default_container_file.inc
container_name=$(parseContainerArgs $*)
if [ -z ${container_name} ]; then
exit 1
fi
sudo docker exec -ti ${container_name} sh -c "cd /home/appimage && /bin/bash -l"
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 CONTAINER_NAME" >&2
exit 1
fi
sudo docker exec -ti $1 sh -c "cd /home/appimage && /bin/bash -l"
#!/bin/bash
function findContainerName {
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
container_file=`${DIR}/find_up ./ -name .container_name`
if [ ! -z ${container_file} ]; then
cat ${container_file}
fi
}
function parseContainerArgs {
container_name=
if [ "$#" -ne 1 ]; then
if [ "$#" -eq 0 ]; then
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
container_name=$(findContainerName)
fi
if [ -z ${container_name} ]; then
echo "Usage: $0 CONTAINER_NAME" >&2
exit 1
fi
else
container_name=$1
fi
echo ${container_name}
}
#!/bin/bash
set -e
path="$1"
shift 1
while [[ $path != / ]];
do
find "$path" -maxdepth 1 -mindepth 1 "$@"
# Note: if you want to ignore symlinks, use "$(realpath -s "$path"/..)"
path="$(readlink -f "$path"/..)"
done
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${DIR}/find_default_container_file.inc
container_name=$(parseContainerArgs $*)
if [ -z ${container_name} ]; then
exit 1
fi
if [ ! -e /proc/driver/nvidia/version ]; then
echo "Cannot find NVIDIA bestion file: /proc/driver/nvidia/version"
exit 1
fi
nvidia_version=$(cat /proc/driver/nvidia/version | head -n 1 | awk '{ print $8 }')
driver_file=NVIDIA-Linux-x86_64-${nvidia_version}.run
driver_url=http://download.nvidia.com/XFree86/Linux-x86_64/${nvidia_version}/${driver_file}
if [ ! -f persistent/${driver_file} ]; then
(
cd persistent
wget http://download.nvidia.com/XFree86/Linux-x86_64/${nvidia_version}/${driver_file} || exit 1
chmod a+x ${driver_file}
)
fi
if [ -f persistent/${driver_file} ]; then
sudo docker exec -ti -u root ${container_name} /home/appimage/persistent/${driver_file} -a -N --ui=none --no-kernel-module -s
else
echo "Cannot find the driver file: ${driver_file}"
exit 1
fi
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${DIR}/find_default_container_file.inc
container_name=$(parseContainerArgs $*)
if [ -z ${container_name} ]; then
exit 1
fi
sudo docker exec -ti ${container_name} /bin/bash -c 'source /home/appimage/devenv.inc; /home/appimage/qtcreator/bin/qtcreator.sh'
......@@ -5,6 +5,11 @@ if [ "$#" -ne 2 ]; then
exit 1
fi
NVIDIA_OPTS=
if [ -e /dev/nvidiactl ]; then
NVIDIA_OPTS+="--device /dev/nvidia0 --device /dev/nvidiactl --device /dev/nvidia-uvm"
fi
sudo docker run -P -t -d \
-v $(pwd)/persistent/:/home/appimage/persistent/:rw \
-v /tmp/.X11-unix/:/tmp/.X11-unix \
......@@ -16,6 +21,11 @@ sudo docker run -P -t -d \
--security-opt seccomp=unconfined \
--device /dev/dri \
--device /dev/snd \
-p127.0.0.1:2022:22 \
$NVIDIA_OPTS \
--name $2 \
$1
$1 || exit 1
if [ ! -f .container_name ]; then
echo $2 > .container_name
fi
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${DIR}/find_default_container_file.inc
container_name=$(parseContainerArgs $*)
if [ -z ${container_name} ]; then
exit 1
fi
sudo docker start ${container_name}
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${DIR}/find_default_container_file.inc
container_name=$(parseContainerArgs $*)
if [ -z ${container_name} ]; then
exit 1
fi
sudo docker stop ${container_name}
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${DIR}/find_default_container_file.inc
container_name=$(parseContainerArgs $*)
if [ -z ${container_name} ]; then
exit 1
fi
sudo docker exec -user root -ti ${container_name} sh -c "cd /home/appimage && /bin/bash -l"
......@@ -21,6 +21,6 @@ prepend PKG_CONFIG_PATH $DEPSDIR/lib/pkgconfig
prepend CMAKE_PREFIX_PATH $DEPSDIR
#prepend PYTHONPATH $DEPSDIR/lib/python3.5/
#prepend PYTHONPATH $DEPSDIR/sip
prepend PYTHONPATH $DEPSDIR/sip
#prepend PYQT_SIP_DIR_OVERRIDE $DEPSDIR/share/sip
......@@ -4,5 +4,5 @@ cmake -DCMAKE_INSTALL_PREFIX=${KRITADIR} \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_TESTING=TRUE \
-DHIDE_SAFE_ASSERTS=FALSE \
-DPYQT_SIP_DIR_OVERRIDE=~/appimage-workspace/deps/usr/share/sip
-DPYQT_SIP_DIR_OVERRIDE=~/appimage-workspace/deps/usr/share/sip \
$@
......@@ -47,6 +47,7 @@ class KRITAIMAGE_EXPORT KisWarpTransformWorker : public QObject
public:
typedef enum WarpType_ {AFFINE_TRANSFORM = 0, SIMILITUDE_TRANSFORM, RIGID_TRANSFORM, N_MODES} WarpType;
typedef enum WarpCalculation_ {GRID = 0, DRAW} WarpCalculation;
static QPointF affineTransformMath(QPointF v, QVector<QPointF> p, QVector<QPointF> q, qreal alpha);
static QPointF similitudeTransformMath(QPointF v, QVector<QPointF> p, QVector<QPointF> q, qreal alpha);
......@@ -75,6 +76,7 @@ private:
private:
WarpMathFunction m_warpMathFunction;
WarpCalculation m_warpCalc;
QVector<QPointF> m_origPoint;
QVector<QPointF> m_transfPoint;
qreal m_alpha;
......
......@@ -57,6 +57,7 @@
#include <KoVBox.h>
#include <klocalizedstring.h>
#include <kformat.h>
#include <kundo2stack.h>
#include <KoResourcePaths.h>
#include "kis_action_registry.h"
......@@ -710,8 +711,8 @@ PerformanceTab::PerformanceTab(QWidget *parent, const char *name)
: WdgPerformanceSettings(parent, name)
{
KisImageConfig cfg;
const int totalRAM = cfg.totalRAM();
lblTotalMemory->setText(i18n("%1 MiB", totalRAM));
const double totalRAM = cfg.totalRAM();
lblTotalMemory->setText(KFormat().formatByteSize(totalRAM * 1024 * 1024, 0, KFormat::IECBinaryDialect, KFormat::UnitMegaByte));
sliderMemoryLimit->setSuffix(i18n(" %"));
sliderMemoryLimit->setRange(1, 100, 2);
......
......@@ -13,7 +13,7 @@ Name[en_GB]=Last Documents Docker
Name[es]=Panel de últimos documentos
Name[gl]=Doca dos últimos documentos
Name[it]=Area di aggancio Ultimi documenti
Name[nl]=Vastzetter van laatste documenten
Name[nl]=Laatste documenten verankering
Name[pl]=Dok ostatnich dokumentów
Name[pt]=Área dos Últimos Documentos
Name[sv]=Dockningsfönster för senaste dokument
......
......@@ -14,7 +14,7 @@ Name[en_GB]=Quick Settings Docker
Name[es]=Panel de ajustes rápidos
Name[gl]=Doca de configuración rápida
Name[it]=Area di aggancio delle impostazioni rapide
Name[nl]=Docker voor snelle instellingen
Name[nl]=Verankering voor snelle instellingen
Name[pl]=Dok szybkich ustawień
Name[pt]=Área de Configuração Rápida
Name[sv]=Dockningspanel med snabbinställningar
......
......@@ -13,7 +13,7 @@ Name[en_GB]=Script Docker
Name[es]=Panel de guiones
Name[gl]=Doca de scripts
Name[it]=Area di aggancio degli script
Name[nl]=Vastzetten van scripts
Name[nl]=Verankering van scripts
Name[pl]=Dok skryptów
Name[pt]=Área de Programas
Name[sv]=Dockningsfönster för skript
......
......@@ -13,7 +13,7 @@ Name[en_GB]=Scripter
Name[es]=Guionador
Name[gl]=Executor de scripts
Name[it]=Scripter
Name[nl]=Scriptschrijver
Name[nl]=Scriptmaker
Name[pl]=Skrypter
Name[pt]=Programador
Name[sv]=Skriptgenerator
......
......@@ -268,11 +268,13 @@ KisToolTransformConfigWidget::KisToolTransformConfigWidget(TransformTransactionP
connect(cmbWarpType, SIGNAL(currentIndexChanged(int)), this, SLOT(notifyEditingFinished()));
connect(m_rotationCenterButtons, SIGNAL(buttonPressed(int)), this, SLOT(notifyEditingFinished()));
connect(aspectButton, SIGNAL(keepAspectRatioChanged(bool)), this, SLOT(notifyEditingFinished()));
connect(defaultRadioButton, SIGNAL(clicked(bool)), this, SLOT(notifyEditingFinished()));
connect(customRadioButton, SIGNAL(clicked(bool)), this, SLOT(notifyEditingFinished()));
connect(lockUnlockPointsButton, SIGNAL(clicked()), this, SLOT(notifyEditingFinished()));
connect(resetPointsButton, SIGNAL(clicked()), this, SLOT(notifyEditingFinished()));
connect(defaultRadioButton, SIGNAL(clicked(bool)), this, SLOT(notifyEditingFinished()));
connect(customRadioButton, SIGNAL(clicked(bool)), this, SLOT(notifyEditingFinished()));
// Liquify
//
// liquify brush options do not affect the image directly and are not
......@@ -786,6 +788,7 @@ void KisToolTransformConfigWidget::slotSetWarpModeButtonClicked(bool value)
ToolTransformArgs *config = m_transaction->currentConfig();
config->setMode(ToolTransformArgs::WARP);
config->setWarpCalculation(KisWarpTransformWorker::WarpCalculation::GRID);
emit sigResetTransform();
}
......@@ -1194,11 +1197,16 @@ void KisToolTransformConfigWidget::activateCustomWarpPoints(bool enabled)
if (!enabled) {
config->setEditingTransformPoints(false);
setDefaultWarpPoints(densityBox->value());
config->setWarpCalculation(KisWarpTransformWorker::WarpCalculation::GRID);
} else {
config->setEditingTransformPoints(true);
config->setWarpCalculation(KisWarpTransformWorker::WarpCalculation::DRAW);
setDefaultWarpPoints(0);
}
updateLockPointsButtonCaption();
}
......
......@@ -30,7 +30,7 @@
#include "kis_cursor.h"
#include "kis_transform_utils.h"
#include "kis_algebra_2d.h"
#include "KisHandlePainterHelper.h"
struct KisWarpTransformStrategy::Private
{
......@@ -43,8 +43,8 @@ struct KisWarpTransformStrategy::Private
currentArgs(_currentArgs),
transaction(_transaction),
lastNumPoints(0),
drawConnectionLines(true),
drawOrigPoints(true),
drawConnectionLines(false), // useful while developing
drawOrigPoints(false),
drawTransfPoints(true),
closeOnStartPointClick(false),
clipOriginalPointsPosition(true),
......@@ -237,7 +237,6 @@ void KisWarpTransformStrategy::paint(QPainter &gc)
gc.save();
gc.setTransform(m_d->handlesTransform, true);
// draw connecting lines
if (m_d->drawConnectionLines) {
gc.setOpacity(0.5);
......@@ -247,12 +246,15 @@ void KisWarpTransformStrategy::paint(QPainter &gc)
m_d->currentArgs.isEditingTransformPoints());
}
QPen mainPen(Qt::black);
QPen outlinePen(Qt::white);
// draw handles
{
const int numPoints = m_d->currentArgs.origPoints().size();
QPen mainPen(Qt::black);
QPen outlinePen(Qt::white);
qreal handlesExtraScale = KisTransformUtils::scaleFromAffineMatrix(m_d->handlesTransform);
......@@ -313,6 +315,42 @@ void KisWarpTransformStrategy::paint(QPainter &gc)
}
}
// draw grid lines only if we are using the GRID mode.
if (m_d->currentArgs.warpCalculation() == KisWarpTransformWorker::WarpCalculation::GRID) {
// see how many rows we have. we are only going to do lines up to 6 divisions/
// it is almost impossible to use with 6 even.
const int numPoints = m_d->currentArgs.origPoints().size();
// grid is always square, so get the square root to find # of rows
int rowsInWarp = sqrt(m_d->currentArgs.origPoints().size());
KisHandlePainterHelper handlePainter(&gc);
handlePainter.setHandleStyle(KisHandleStyle::primarySelection());
// draw horizontal lines
for (int i = 0; i < numPoints; i++) {
if (i != 0 && i % rowsInWarp == rowsInWarp -1) {
// skip line if it is the last in the row
} else {
handlePainter.drawConnectionLine(m_d->currentArgs.transfPoints()[i], m_d->currentArgs.transfPoints()[i+1] );
}
}
// draw vertical lines
for (int i = 0; i < numPoints; i++) {
if ( (numPoints - i - 1) < rowsInWarp ) {
// last row doesn't need to draw vertical lines
} else {
handlePainter.drawConnectionLine(m_d->currentArgs.transfPoints()[i], m_d->currentArgs.transfPoints()[i+rowsInWarp] );
}
}
} // end if statement
gc.restore();
}
......
......@@ -131,6 +131,13 @@ public:
inline void setWarpType(KisWarpTransformWorker::WarpType warpType) {
m_warpType = warpType;
}
inline void setWarpCalculation(KisWarpTransformWorker::WarpCalculation warpCalc) {
m_warpCalculation = warpCalc;
}
inline KisWarpTransformWorker::WarpCalculation warpCalculation() {
return m_warpCalculation;
}
inline void setAlpha(double alpha) {
m_alpha = alpha;
}
......@@ -284,6 +291,7 @@ private:
QVector<QPointF> m_origPoints;
QVector<QPointF> m_transfPoints;
KisWarpTransformWorker::WarpType m_warpType;
KisWarpTransformWorker::WarpCalculation m_warpCalculation; // DRAW or GRID
double m_alpha;
//'free transform'-related
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>479</width>
<width>489</width>
<height>674</height>
</rect>
</property>
......@@ -250,7 +250,7 @@
<enum>QFrame::Raised</enum>
</property>
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="freeTransformWidget">
<layout class="QVBoxLayout" name="verticalLayout">
......@@ -1535,7 +1535,10 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>0</number>
<number>2</number>
</property>
<property name="maximum">
<number>30</number>
</property>
<property name="value">
<number>3</number>
......@@ -2198,7 +2201,7 @@
<connections/>
<buttongroups>
<buttongroup name="freeTransformRadioGroup"/>
<buttongroup name="buttonGroup"/>
<buttongroup name="cageTransformButtonGroup"/>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment