|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
extragear/graphics/kcoloreditSVN commit 834470 by aucahuasi:
GUI: change brief view strings * Improved the color names generation (now is fast) * Added argument to load palette files from terminal M +0 -3 desktop/kcoloreditui.rc M +43 -40 src/app/kcoloredit.cpp M +2 -0 src/app/kcoloredit.h M +11 -24 src/app/main.cpp M +22 -7 src/core/palettemodel.cpp M +3 -0 src/core/palettemodel.h M +2 -2 src/itemviews/palettedetailview.cpp M +1 -1 src/widgets/colorinfo/colorinfotext.h --- trunk/extragear/graphics/kcoloredit/desktop/kcoloreditui.rc #834469:834470 @@ -12,9 +12,6 @@ <Action name="generate-color-names"/> <Action name="complete-color-names"/> </Menu> - <Menu name="tools"> - <Action name="show-brief-view"/> - </Menu> </MenuBar> <ToolBar name="palette-toolbar" newline="true"> <text>Palette Toolbar</text> --- trunk/extragear/graphics/kcoloredit/src/app/kcoloredit.cpp #834469:834470 @@ -52,6 +52,42 @@ { } +void KColorEditMainWnd::openPaletteFile(const QString & file) +{ + QString fileNameFromDialog = file; + + QString tmpFile; + + if (!fileNameFromDialog.isEmpty()) + { + if (KIO::NetAccess::download(fileNameFromDialog, tmpFile, this)) + { + if (m_paletteDocument->openPaletteFile(tmpFile)) + { + m_paletteDetailView->setModel(m_paletteDocument->model()); + m_paletteDetailView->updateHeaders(QModelIndex(), QModelIndex()); + + m_paletteBriefView->setModel(m_paletteDocument->model()); + + m_kColorEditWidget->setModel(m_paletteDocument->model()); + + // NOTE little hack to force the signal dataChange to update the gridView + if (m_paletteDocument->model()->rowCount() > 0) + m_paletteDocument->model()->setData(m_paletteDocument->model()->index(0, 0), m_paletteDocument->model()->index(0, 0).data()); + + updateTittleWhenOpenSaveDoc(); + } + else + KMessageBox::error(this, m_paletteDocument->lastErrorString()); + + KIO::NetAccess::removeTempFile(tmpFile); + } + else + KMessageBox::error(this, KIO::NetAccess::lastErrorString()); + } + +} + //BEGIN public slots void KColorEditMainWnd::newFile() @@ -160,51 +196,18 @@ { if (m_paletteDocument->model()->rowCount() > 0) if (KMessageBox::questionYesNo(this - , i18n("This action will replace the name of all color items with names in this format #RRGGBB.") - , QString() - , KGuiItem(i18n("Generate Color Names"), KIcon("format-stroke-color")) - , KStandardGuiItem::cancel()) - == KMessageBox::Yes) - { - QVariantMap vmap; - - int rows = m_paletteDocument->model()->rowCount(); - - for (int i = 0; i < rows; i++) - { - vmap = m_paletteDocument->model()->index(i, 0).data().toMap(); - - if (vmap.value("type").toString() == QString("color")) - { - vmap.insert("name", vmap.value("color").value<QColor>().name()); - - m_paletteDocument->model()->setData(m_paletteDocument->model()->index(i, 0), vmap); - } - } - } + , i18n("This action will replace the name of all color items with names in this format #RRGGBB.") + , QString() + , KGuiItem(i18n("Generate Color Names"), KIcon("format-stroke-color")) + , KStandardGuiItem::cancel()) + == KMessageBox::Yes) + m_paletteDocument->model()->generateColorNames(); } void KColorEditMainWnd::completeColorNames() { if (m_paletteDocument->model()->rowCount() > 0) - { - QVariantMap vmap; - - int rows = m_paletteDocument->model()->rowCount(); - - for (int i = 0; i < rows; i++) - { - vmap = m_paletteDocument->model()->index(i, 0).data().toMap(); - - if (vmap.value("type").toString() == QString("color")) - if (vmap.value("name").toString().isEmpty()) - { - vmap.insert("name", vmap.value("color").value<QColor>().name()); - - m_paletteDocument->model()->setData(m_paletteDocument->model()->index(i, 0), vmap); - } - } - } + m_paletteDocument->model()->completeColorNames(); } void KColorEditMainWnd::addColorItem() --- trunk/extragear/graphics/kcoloredit/src/app/kcoloredit.h #834469:834470 @@ -38,6 +38,8 @@ KColorEditMainWnd(QWidget * parent = 0, Qt::WindowFlags f = KDE_DEFAULT_WINDOWFLAGS); ~KColorEditMainWnd(); + void openPaletteFile(const QString & file); + public slots: void newFile(); void openFile(); --- trunk/extragear/graphics/kcoloredit/src/app/main.cpp #834469:834470 @@ -19,18 +19,18 @@ #include "kcoloredit.h" +#include <KUrl> #include <KApplication> #include <KCmdLineArgs> #include <KAboutData> - #include <KIcon> inline KAboutData kcoloreditAboutData( const char * name, const char * iname ) { - KAboutData about(name, 0, ki18n(iname), "1.70.00 (KColorEdit 1.7)", + KAboutData about(name, 0, ki18n(iname), "1.90.50 (KColorEdit 2 Beta 1)", ki18n(I18N_NOOP("KColorEdit, great tool for editing color palettes.")), KAboutData::License_GPL, ki18n("(C) 2008, Percy Camilo Triveño Aucahuasi\n" "(C) 2000, Artur Rataj")); - about.addAuthor(ki18n("Percy Camilo Triveño Aucahuasi"), ki18n("Current maintainer - Upgraded KColorEdit to KDE 4"), "orgyforever@..."); + about.addAuthor(ki18n("Percy Camilo Triveño Aucahuasi"), ki18n("Current maintainer - Upgraded and developed the new version."), "orgyforever@..."); about.addAuthor(ki18n("Artur Rataj"), ki18n("Former maintainer - Created KColorEdit"), "art@..."); return about; @@ -43,35 +43,22 @@ KCmdLineArgs::init(argc, argv, &about); KCmdLineOptions options; - options.add("+[File]", ki18n("File to open")); + options.add("+[URL]", ki18n("File to open (Text file with colors and comments items)")); KCmdLineArgs::addCmdLineOptions(options); KApplication app; QApplication::setWindowIcon(KIcon("kcoloredit")); - // check if we are starting with session management - if (app.isSessionRestored()) - { - RESTORE(KColorEditMainWnd); - } - else - { - KColorEditMainWnd * kceWindow = new KColorEditMainWnd(); - kceWindow->show(); + KCmdLineArgs * args = KCmdLineArgs::parsedArgs(); - KCmdLineArgs * args = KCmdLineArgs::parsedArgs(); + KColorEditMainWnd * kceMainWnd = new KColorEditMainWnd(); - if (args->count()) - { - //kcoloredit->openDocumentFile(args->arg(0).toLocal8Bit().data()); - } - else - { - //kcoloredit->openDocumentFile(); - } + if (args->count()) + kceMainWnd->openPaletteFile(args->url(0).url()); - args->clear(); - } + kceMainWnd->show(); + args->clear(); + return app.exec(); } --- trunk/extragear/graphics/kcoloredit/src/core/palettemodel.cpp #834469:834470 @@ -83,10 +83,8 @@ if (m_palette.itemType(index.row()) == PaletteItem::ColorType) { - //vmap.insert("type", QString("color")); + data(index, Qt::BackgroundRole).toMap().insert("type", QString("color")); // NOTE - index.model()->data(index, Qt::BackgroundRole).toMap().insert("type", QString("color")); // NOTE - PaletteColorItem * colorItem = m_palette.colorItem(index.row()); if (colorItem) @@ -102,10 +100,8 @@ if (m_palette.itemType(index.row()) == PaletteItem::CommentType) { - //vmap.insert("type", QString("comment")); + data(index, Qt::BackgroundRole).toMap().insert("type", QString("comment")); // NOTE - index.model()->data(index, Qt::BackgroundRole).toMap().insert("type", QString("comment")); // NOTE - PaletteCommentItem * commentItem = m_palette.commentItem(index.row()); if (commentItem) @@ -127,7 +123,7 @@ if (orientation == Qt::Horizontal) if (section == 0) - return i18n("Palette items"); + return i18n("Items"); if (orientation == Qt::Vertical) return QString("%1").arg(section + 1); @@ -218,6 +214,25 @@ return m_palette.fullDescription(); } +void PaletteModel::generateColorNames() +{ + for (int i = 0; i < m_palette.count(); i++) + if (m_palette.itemType(i) == PaletteItem::ColorType) + m_palette.colorItem(i)->setColorName(m_palette.colorItem(i)->color().name()); + + emit dataChanged(QModelIndex(), QModelIndex()); +} + +void PaletteModel::completeColorNames() +{ + for (int i = 0; i < m_palette.count(); i++) + if (m_palette.itemType(i) == PaletteItem::ColorType) + if (m_palette.colorItem(i)->colorName().isEmpty()) + m_palette.colorItem(i)->setColorName(m_palette.colorItem(i)->color().name()); + + emit dataChanged(QModelIndex(), QModelIndex()); +} + //END public methods #include "palettemodel.moc" --- trunk/extragear/graphics/kcoloredit/src/core/palettemodel.h #834469:834470 @@ -55,6 +55,9 @@ QString briefDescription() const; QString fullDescription() const; + void generateColorNames(); + void completeColorNames(); + private: Palette m_palette; }; --- trunk/extragear/graphics/kcoloredit/src/itemviews/palettedetailview.cpp #834469:834470 @@ -54,13 +54,13 @@ // NOTE update headers when start the app updateHeaders(QModelIndex(), QModelIndex()); - QLabel * m_paletteNameLabel = new QLabel(i18n("Palette Name"), this); + QLabel * m_paletteNameLabel = new QLabel(i18n("Name"), this); m_paletteNameLineEdit = new KLineEdit(this); m_paletteNameLineEdit->setClearButtonShown(true); m_paletteNameLineEdit->setText(m_model->paletteName()); - QLabel * m_paletteDescriptionLabel = new QLabel(i18n("Palette Description"), this); + QLabel * m_paletteDescriptionLabel = new QLabel(i18n("Description"), this); m_paletteDescriptionLabel->setAlignment(Qt::AlignCenter); KComboBox * descriptionModeComboBox = new KComboBox(this); --- trunk/extragear/graphics/kcoloredit/src/widgets/colorinfo/colorinfotext.h #834469:834470 @@ -29,7 +29,7 @@ class ColorInfoText : public ColorInfo { Q_OBJECT - +//KIntSpinBox public: ColorInfoText(QWidget * parent = 0); virtual ~ColorInfoText(); _______________________________________________ kde-docbook mailing list kde-docbook@... https://mail.kde.org/mailman/listinfo/kde-docbook |
| Free embeddable forum powered by Nabble | Forum Help |