Commit 35a5fdf0 authored by Martin Koller's avatar Martin Koller

start porting away from KDE4Support classes

parent 9e964ce2
......@@ -94,20 +94,6 @@ add_subdirectory( doc )
########### next target ###############
macro(CREATE_VERSION _in_FILE _out_FILE)
FILE(READ ${_in_FILE} _contents)
FILE(WRITE ${_out_FILE} "static const char * const kpVersionText =")
STRING(REGEX REPLACE "\n" "" _contents "${_contents}" )
FILE(APPEND ${_out_FILE} "${_contents}")
FILE(APPEND ${_out_FILE} ";\n")
endmacro(CREATE_VERSION)
#macro_additional_clean_files( ${CMAKE_CURRENT_BINARY_DIR}/kolourpaintversion.h )
create_version(${CMAKE_CURRENT_SOURCE_DIR}/VERSION ${CMAKE_CURRENT_BINARY_DIR}/kolourpaintversion.h)
macro(CREATE_LICENSE _in_FILE _out_FILE)
FILE(READ ${_in_FILE} _contents)
FILE(WRITE ${_out_FILE} "static const char * const kpLicenseText =")
......
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
......@@ -39,9 +38,8 @@
#include <QHBoxLayout>
#include <QPushButton>
#include <QTableWidget>
#include <KDoubleNumInput>
#include <KIntNumInput>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <KLocalizedString>
#include <KMessageBox>
#include <KDebug>
......@@ -54,8 +52,8 @@ struct kpDocumentMetaInfoDialogPrivate
{
const kpDocumentMetaInfo *originalMetaInfoPtr;
KDoubleNumInput *horizDpiInput, *vertDpiInput;
KIntNumInput *horizOffsetInput, *vertOffsetInput;
QDoubleSpinBox *horizDpiInput, *vertDpiInput;
QSpinBox *horizOffsetInput, *vertOffsetInput;
QTableWidget *fieldsTableWidget;
QPushButton *fieldsAddRowButton, *fieldsDeleteRowButton, *fieldsResetButton;
......@@ -136,48 +134,38 @@ kpDocumentMetaInfoDialog::kpDocumentMetaInfoDialog (
// DPI Group Box
//
Q_ASSERT (::DpiInputMin < ::DpiInputMax);
QGroupBox *dpiGroupBox = new QGroupBox (i18n ("Dots &Per Inch (DPI)"),
baseWidget);
QGroupBox *dpiGroupBox = new QGroupBox(i18n("Dots &Per Inch (DPI)"), baseWidget);
d->horizDpiInput = new KDoubleNumInput (
::DpiInputMin/*lower*/,
::DpiInputMax/*upper*/,
0/*value*/,
dpiGroupBox,
::DpiInputStep/*step*/,
::DpiPrecision/*precision*/);
d->horizDpiInput->setLabel (i18n ("Horizontal:"),
Qt::AlignTop | Qt::AlignHCenter);
d->horizDpiInput->setSpecialValueText (i18n ("Unspecified"));
d->horizDpiInput = new QDoubleSpinBox(dpiGroupBox);
d->horizDpiInput->setRange(::DpiInputMin, ::DpiInputMax);
d->horizDpiInput->setValue(0.0);
d->horizDpiInput->setSingleStep(::DpiInputStep);
d->horizDpiInput->setDecimals(::DpiPrecision);
d->horizDpiInput->setSpecialValueText(i18n("Unspecified"));
QLabel *dpiXLabel = new QLabel (
i18nc ("Horizontal DPI 'x' Vertical DPI", " x "), dpiGroupBox);
dpiXLabel->setAlignment (Qt::AlignCenter);
d->vertDpiInput = new KDoubleNumInput (
::DpiInputMin/*lower*/,
::DpiInputMax/*upper*/,
0/*value*/,
dpiGroupBox,
::DpiInputStep/*step*/,
::DpiPrecision/*precision*/);
d->vertDpiInput->setLabel (i18n ("Vertical:"),
Qt::AlignTop | Qt::AlignHCenter);
d->vertDpiInput->setSpecialValueText (i18n ("Unspecified"));
d->vertDpiInput = new QDoubleSpinBox(dpiGroupBox);
d->vertDpiInput->setRange(::DpiInputMin, ::DpiInputMax);
d->vertDpiInput->setValue(0.0);
d->vertDpiInput->setSingleStep(::DpiInputStep);
d->vertDpiInput->setDecimals(::DpiPrecision);
d->vertDpiInput->setSpecialValueText(i18n("Unspecified"));
QGridLayout *dpiLay = new QGridLayout (dpiGroupBox);
QGridLayout *dpiLay = new QGridLayout(dpiGroupBox);
dpiLay->addWidget (d->horizDpiInput, 0, 0);
dpiLay->addWidget (dpiXLabel, 0, 1);
dpiLay->addWidget (d->vertDpiInput, 0, 2);
dpiLay->addWidget(new QLabel(i18n("Horizontal:")), 0, 0, Qt::AlignHCenter);
dpiLay->addWidget(d->horizDpiInput, 1, 0);
dpiLay->addWidget(dpiXLabel, 0, 1);
dpiLay->addWidget(new QLabel(i18n("Vertical:")), 0, 2, Qt::AlignHCenter);
dpiLay->addWidget(d->vertDpiInput, 1, 2);
dpiLay->addItem (new QSpacerItem (0/*width*/, 0/*height*/),
1, 0, 1/*row span*/, 3/*col span*/);
dpiLay->setRowStretch (1, 1);
dpiLay->setRowStretch(2, 1);
dpiGroupBox->setWhatsThis (
......@@ -212,34 +200,22 @@ kpDocumentMetaInfoDialog::kpDocumentMetaInfoDialog (
// Offset Group Box
//
QGroupBox *offsetGroupBox = new QGroupBox(i18n ("O&ffset"), baseWidget);
QGroupBox *offsetGroupBox = new QGroupBox (i18n ("O&ffset"), baseWidget);
d->horizOffsetInput = new KIntNumInput (offsetGroupBox);
d->horizOffsetInput->setLabel (i18n ("Horizontal:"),
Qt::AlignTop | Qt::AlignHCenter);
d->horizOffsetInput->setRange (
kpDocumentMetaInfo::MinOffset,
kpDocumentMetaInfo::MaxOffset);
d->horizOffsetInput->setSliderEnabled(false);
d->vertOffsetInput = new KIntNumInput (offsetGroupBox);
d->vertOffsetInput->setLabel (i18n ("Vertical:"),
Qt::AlignTop | Qt::AlignHCenter);
d->vertOffsetInput->setRange (
kpDocumentMetaInfo::MinOffset,
kpDocumentMetaInfo::MaxOffset);
d->vertOffsetInput->setSliderEnabled(false);
d->horizOffsetInput = new QSpinBox;
d->horizOffsetInput->setRange(kpDocumentMetaInfo::MinOffset, kpDocumentMetaInfo::MaxOffset);
d->vertOffsetInput = new QSpinBox;
d->vertOffsetInput->setRange(kpDocumentMetaInfo::MinOffset, kpDocumentMetaInfo::MaxOffset);
QGridLayout *offsetLay = new QGridLayout (offsetGroupBox);
QGridLayout *offsetLay = new QGridLayout(offsetGroupBox);
offsetLay->addWidget (d->horizOffsetInput, 0, 0);
offsetLay->addWidget (d->vertOffsetInput, 0, 1);
offsetLay->addWidget(new QLabel(i18n("Horizontal:")), 0, 0, Qt::AlignHCenter);
offsetLay->addWidget(d->horizOffsetInput, 1, 0);
offsetLay->addWidget(new QLabel(i18n("Vertical:")), 0, 1, Qt::AlignHCenter);
offsetLay->addWidget(d->vertOffsetInput, 1, 1);
offsetLay->addItem (new QSpacerItem (0/*width*/, 0/*height*/),
1, 0, 1/*row span*/, 2/*col span*/);
offsetLay->setRowStretch (1, 1);
offsetLay->setRowStretch (2, 1);
offsetGroupBox->setWhatsThis (
......
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
......@@ -36,6 +35,7 @@
#include <qlabel.h>
#include <qlayout.h>
#include <QImage>
#include <QSpinBox>
#include <qpolygon.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
......@@ -43,7 +43,6 @@
#include <kdebug.h>
#include <kiconloader.h>
#include <knuminput.h>
#include <klocale.h>
#include <kpDefs.h>
......@@ -140,9 +139,10 @@ void kpTransformRotateDialog::createAngleGroupBox ()
m_angle270RadioButton = new QRadioButton (i18n ("270 de&grees"), angleGroupBox);
m_angleCustomRadioButton = new QRadioButton (i18n ("C&ustom:"), angleGroupBox);
m_angleCustomInput = new KIntNumInput (s_lastAngleCustom, angleGroupBox);
m_angleCustomInput->setMinimum (-359);
m_angleCustomInput->setMaximum (+359);
m_angleCustomInput = new QSpinBox;
m_angleCustomInput->setMinimum(-359);
m_angleCustomInput->setMaximum(+359);
m_angleCustomInput->setValue(s_lastAngleCustom);
QLabel *degreesLabel = new QLabel (i18n ("degrees"), angleGroupBox);
......@@ -240,7 +240,7 @@ void kpTransformRotateDialog::slotAngleCustomRadioButtonToggled (bool isChecked)
m_angleCustomInput->setEnabled (isChecked);
if (isChecked)
m_angleCustomInput->setEditFocus ();
m_angleCustomInput->setFocus();
}
// private slot virtual [base kpTransformPreviewDialog]
......
......@@ -39,8 +39,7 @@
class QButtonGroup;
class QRadioButton;
class KIntNumInput;
class QSpinBox;
class kpTransformRotateDialog : public kpTransformPreviewDialog
......@@ -86,7 +85,7 @@ private:
*m_angle180RadioButton,
*m_angle270RadioButton,
*m_angleCustomRadioButton;
KIntNumInput *m_angleCustomInput;
QSpinBox *m_angleCustomInput;
};
......
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
Copyright (c) 2015 Martin Koller <kollix@aon.at>
All rights reserved.
Redistribution and use in source and binary forms, with or without
......@@ -26,94 +26,92 @@
*/
#include <k4aboutdata.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kdebug.h>
#include <kimageio.h>
#include <klocale.h>
#include <KMessageBox>
#include <kaboutdata.h>
#include <kdeversion.h>
#include <kpDefs.h>
#include <kpMainWindow.h>
#include <kolourpaintlicense.h>
#include <kolourpaintversion.h>
#include <QApplication>
#include <QCommandLineParser>
int main (int argc, char *argv [])
int main(int argc, char *argv [])
{
K4AboutData aboutData
(
"kolourpaint", 0,
ki18n ("KolourPaint"),
kpVersionText,
ki18n ("Paint Program for KDE"),
K4AboutData::License_Custom,
ki18n (0/*copyright statement - see license instead*/),
ki18n ("To obtain support, please visit the website."),
"http://www.kolourpaint.org/"
);
// (this is _not_ the same as KAboutData::License_BSD)
aboutData.setLicenseText (ki18n (kpLicenseText));
// Please add yourself here if you feel you're missing.
// SYNC: with AUTHORS
aboutData.addAuthor (ki18n ("Clarence Dang"), ki18n ("Project Founder"), "dang@kde.org");
aboutData.addAuthor (ki18n ("Thurston Dang"), ki18n ("Chief Investigator"),
"thurston_dang@users.sourceforge.net");
aboutData.addAuthor (ki18n ("Martin Koller"), ki18n ("Scanning Support, Alpha Support, Current Maintainer"), "kollix@aon.at");
aboutData.addAuthor (ki18n ("Kristof Borrey"), ki18n ("Icons"), "borrey@kde.org");
aboutData.addAuthor (ki18n ("Tasuku Suzuki"), ki18n ("InputMethod Support"), "stasuku@gmail.com");
aboutData.addAuthor (ki18n ("Kazuki Ohta"), ki18n ("InputMethod Support"), "mover@hct.zaq.ne.jp");
aboutData.addAuthor (ki18n ("Nuno Pinheiro"), ki18n ("Icons"), "nf.pinheiro@gmail.com");
aboutData.addAuthor (ki18n ("Danny Allen"), ki18n ("Icons"), "dannya40uk@yahoo.co.uk");
aboutData.addAuthor (ki18n ("Mike Gashler"), ki18n ("Image Effects"), "gashlerm@yahoo.com");
aboutData.addAuthor (ki18n ("Laurent Montel"), ki18n ("KDE 4 Porting"), "montel@kde.org");
// TODO: missing a lot of people who helped with the KDE 4 port.
aboutData.addCredit (ki18n ("Thanks to the many others who have helped to make this program possible."));
KCmdLineArgs::init (argc, argv, &aboutData);
KCmdLineOptions cmdLineOptions;
cmdLineOptions.add ("+[file]", ki18n ("Image file to open"));
KCmdLineArgs::addCmdLineOptions (cmdLineOptions);
KApplication app;
if (app.isSessionRestored ())
KAboutData aboutData
(
"kolourpaint",
i18n("KolourPaint"),
KDE_VERSION_STRING,
i18n("Paint Program for KDE"),
KAboutLicense::Custom,
QString(), // copyright statement - see license instead
QString(), // other text
QLatin1String("http://www.kolourpaint.org/") // home page
);
// (this is _not_ the same as KAboutLicense::BSD)
aboutData.setLicenseText(i18n(kpLicenseText));
// Please add yourself here if you feel you're missing.
// SYNC: with AUTHORS
aboutData.addAuthor(i18n("Clarence Dang"), i18n("Project Founder"), QLatin1String("dang@kde.org"));
aboutData.addAuthor(i18n("Thurston Dang"), i18n("Chief Investigator"),
QLatin1String("thurston_dang@users.sourceforge.net"));
aboutData.addAuthor(i18n("Martin Koller"), i18n("Scanning Support, Alpha Support, Current Maintainer"),
QLatin1String("kollix@aon.at"));
aboutData.addAuthor(i18n("Kristof Borrey"), i18n("Icons"), QLatin1String("borrey@kde.org"));
aboutData.addAuthor(i18n("Tasuku Suzuki"), i18n("InputMethod Support"), QLatin1String("stasuku@gmail.com"));
aboutData.addAuthor(i18n("Kazuki Ohta"), i18n("InputMethod Support"), QLatin1String("mover@hct.zaq.ne.jp"));
aboutData.addAuthor(i18n("Nuno Pinheiro"), i18n("Icons"), QLatin1String("nf.pinheiro@gmail.com"));
aboutData.addAuthor(i18n("Danny Allen"), i18n("Icons"), QLatin1String("dannya40uk@yahoo.co.uk"));
aboutData.addAuthor(i18n("Mike Gashler"), i18n("Image Effects"), QLatin1String("gashlerm@yahoo.com"));
aboutData.addAuthor(i18n("Laurent Montel"), i18n("KDE 4 Porting"), QLatin1String("montel@kde.org"));
aboutData.addAuthor(i18n("Christoph Feck"), i18n("KDE 5 Porting"), QLatin1String("christoph@maxiom.de"));
aboutData.addCredit(i18n("Thanks to the many others who have helped to make this program possible."));
QApplication app(argc, argv);
QCommandLineParser cmdLine;
KAboutData::setApplicationData(aboutData);
cmdLine.addVersionOption();
cmdLine.addHelpOption();
cmdLine.addPositionalArgument("files", i18n("Image files to open, optionally"), "[files...]");
aboutData.setupCommandLine(&cmdLine);
cmdLine.process(app);
aboutData.processCommandLine(&cmdLine);
if ( app.isSessionRestored() )
{
// Creates a kpMainWindow using the default constructor and then
// calls kpMainWindow::readProperties().
RESTORE(kpMainWindow)
}
else
{
kpMainWindow *mainWindow;
QStringList args = cmdLine.positionalArguments();
if ( args.count() >= 1 )
{
// Creates a kpMainWindow using the default constructor and then
// calls kpMainWindow::readProperties().
RESTORE (kpMainWindow)
for (int i = 0; i < args.count(); i++)
{
mainWindow = new kpMainWindow(QUrl::fromUserInput(args[i]));
mainWindow->show();
}
}
else
{
kpMainWindow *mainWindow;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs ();
if (args->count () >= 1)
{
for (int i = 0; i < args->count (); i++)
{
mainWindow = new kpMainWindow (args->url (i));
mainWindow->show ();
}
}
else
{
mainWindow = new kpMainWindow ();
mainWindow->show ();
}
args->clear ();
mainWindow = new kpMainWindow();
mainWindow->show();
}
}
return app.exec ();
return app.exec();
}
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
......@@ -32,7 +31,7 @@
#include <QAction>
#include <KActionCollection>
#include <KFileDialog>
#include <QFileDialog>
#include <KMessageBox>
#include <KSelectAction>
#include <KStandardGuiItem>
......@@ -43,12 +42,14 @@
#include <kpColorToolBar.h>
#include <kpUrlFormatter.h>
//---------------------------------------------------------------------
static QStringList KDEColorCollectionNames ()
{
return kpColorCollection::installedCollections ();
}
//---------------------------------------------------------------------
// private
void kpMainWindow::setupColorsMenuActions ()
......@@ -106,6 +107,8 @@ void kpMainWindow::setupColorsMenuActions ()
enableColorsMenuDocumentActions (false);
}
//---------------------------------------------------------------------
// private
void kpMainWindow::createColorBox ()
{
......@@ -118,6 +121,8 @@ void kpMainWindow::createColorBox ()
SLOT (slotUpdateColorsDeleteRowActionEnabled ()));
}
//---------------------------------------------------------------------
// private
void kpMainWindow::enableColorsMenuDocumentActions (bool enable)
{
......@@ -136,6 +141,8 @@ void kpMainWindow::enableColorsMenuDocumentActions (bool enable)
slotUpdateColorsDeleteRowActionEnabled ();
}
//---------------------------------------------------------------------
// private slot
void kpMainWindow::slotUpdateColorsDeleteRowActionEnabled ()
{
......@@ -148,6 +155,8 @@ void kpMainWindow::slotUpdateColorsDeleteRowActionEnabled ()
d->colorMenuDocumentActionsEnabled && (colorCells ()->rowCount () > 0));
}
//---------------------------------------------------------------------
// Used in 2 situations:
//
......@@ -165,6 +174,8 @@ void kpMainWindow::deselectActionColorsKDE ()
d->actionColorsKDE->setCurrentItem (-1);
}
//---------------------------------------------------------------------
// private
bool kpMainWindow::queryCloseColors ()
......@@ -224,6 +235,8 @@ bool kpMainWindow::queryCloseColors ()
}
}
//---------------------------------------------------------------------
// private
void kpMainWindow::openDefaultColors ()
......@@ -232,6 +245,8 @@ void kpMainWindow::openDefaultColors ()
kpColorCells::DefaultColorCollection ());
}
//---------------------------------------------------------------------
// private slot
void kpMainWindow::slotColorsDefault ()
{
......@@ -246,6 +261,8 @@ void kpMainWindow::slotColorsDefault ()
deselectActionColorsKDE ();
}
//---------------------------------------------------------------------
// private
bool kpMainWindow::openKDEColors (const QString &name)
{
......@@ -271,6 +288,8 @@ bool kpMainWindow::openKDEColors (const QString &name)
}
}
//---------------------------------------------------------------------
// private slot
void kpMainWindow::slotColorsKDE ()
{
......@@ -299,6 +318,8 @@ void kpMainWindow::slotColorsKDE ()
deselectActionColorsKDE ();
}
//---------------------------------------------------------------------
// private
bool kpMainWindow::openColors (const QUrl &url)
{
......@@ -308,26 +329,31 @@ bool kpMainWindow::openColors (const QUrl &url)
return true;
}
//---------------------------------------------------------------------
// private slot
void kpMainWindow::slotColorsOpen ()
{
// Call due to dialog.
toolEndShape ();
KFileDialog fd (colorCells ()->url (), QString()/*filter*/, this);
fd.setWindowTitle (i18nc ("@title:window", "Open Color Palette"));
fd.setOperationMode (KFileDialog::Opening);
QFileDialog fd(this);
fd.setDirectoryUrl(colorCells ()->url());
fd.setWindowTitle(i18nc ("@title:window", "Open Color Palette"));
if (fd.exec ())
{
if (!queryCloseColors ())
return;
if (openColors (fd.selectedUrl ()))
deselectActionColorsKDE ();
QList<QUrl> selected = fd.selectedUrls();
if ( selected.count() && openColors(selected[0]) )
deselectActionColorsKDE();
}
}
//---------------------------------------------------------------------
// private slot
void kpMainWindow::slotColorsReload ()
{
......@@ -394,6 +420,8 @@ void kpMainWindow::slotColorsReload ()
}
}
//---------------------------------------------------------------------
// private slot
bool kpMainWindow::slotColorsSave ()
......@@ -409,20 +437,24 @@ bool kpMainWindow::slotColorsSave ()
return colorCells ()->saveColorCollection ();
}
//---------------------------------------------------------------------
// private slot
bool kpMainWindow::slotColorsSaveAs ()
{
// Call due to dialog.
toolEndShape ();
KFileDialog fd (colorCells ()->url (), QString()/*filter*/, this);
fd.setWindowTitle (i18n ("Save Color Palette As"));
fd.setOperationMode (KFileDialog::Saving);
QFileDialog fd(this);
fd.setDirectoryUrl(colorCells ()->url());
fd.setWindowTitle(i18n("Save Color Palette As"));
fd.setAcceptMode(QFileDialog::AcceptSave);
if (fd.exec ())
{
if (!colorCells ()->saveColorCollectionAs (fd.selectedUrl ()))
return false;
QList<QUrl> selected = fd.selectedUrls();
if ( !selected.count() || !colorCells ()->saveColorCollectionAs(selected[0]) )
return false;
// We're definitely using our own color collection now.
deselectActionColorsKDE ();
......@@ -433,6 +465,7 @@ bool kpMainWindow::slotColorsSaveAs ()
return false;
}
//---------------------------------------------------------------------
// private slot
void kpMainWindow::slotColorsAppendRow ()
......@@ -444,6 +477,8 @@ void kpMainWindow::slotColorsAppendRow ()
colorCells->appendRow ();
}
//---------------------------------------------------------------------
// private slot
void kpMainWindow::slotColorsDeleteRow ()
{
......
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
Copyright (c) 2007 Martin Koller <kollix@aon.at>
Copyright (c) 2007 John Layt <john@layt.net>
Copyright (c) 2011 Martin Koller <kollix@aon.at>
Copyright (c) 2007,2011,2015 Martin Koller <kollix@aon.at>
All rights reserved.
Redistribution and use in source and binary forms, with or without
......@@ -37,6 +35,7 @@
#include <QDesktopWidget>
#include <QDialog>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <qpainter.h>
#include <qpixmap.h>
#include <qsize.h>
......@@ -47,6 +46,9 @@
#include <QLabel>
#include <QCheckBox>
#include <QVBoxLayout>
#include <QImageReader>
#include <QImageWriter>
#include <QMimeDatabase>
#include <kactioncollection.h>
#include <kconfig.h>
......@@ -55,7 +57,6 @@
#include <KIntSpinBox>
#include <kfiledialog.h>
#include <kiconloader.h>
#include <kimageio.h>
#include <kio/netaccess.h>
#include <klocale.h>
#include <kmessagebox.h>
......@@ -428,29 +429,39 @@ bool kpMainWindow::open (const QUrl &url, bool newDocSameNameIfNotExist)
// private
QList<QUrl> kpMainWindow::askForOpenURLs(const QString &caption, bool allowMultipleURLs)
{
QStringList mimeTypes = KImageIO::mimeTypes (KImageIO::Reading);
#if DEBUG_KP_MAIN_WINDOW
QStringList sortedMimeTypes = mimeTypes;
sortedMimeTypes.sort ();
kDebug () << "kpMainWindow::askForURLs(allowMultiple="
<< allowMultipleURLs