Skip to content
Browse files

Simplified the Panose widget

  • Loading branch information...
1 parent 539af18 commit 351285a85c6c45bcda39b437712ebb4a09e54d7e Pierre Marchand committed
Showing with 64 additions and 50 deletions.
  1. +4 −0 src/panosewidget.cpp
  2. +6 −0 src/panosewidget.ui
  3. +49 −49 src/tagswidget.cpp
  4. +5 −1 src/tagswidget.h
View
4 src/panosewidget.cpp
@@ -29,6 +29,7 @@
#include <QSettings>
#include <QIcon>
#include <QColor>
+#include <QPalette>
PanoseWidget::PanoseWidget(QWidget *parent) :
@@ -40,6 +41,9 @@ PanoseWidget::PanoseWidget(QWidget *parent) :
m_filter.clear();
m_filterKey = 0;
+ QPalette palette(m_ui->pTree->palette());
+ palette.setBrush(QPalette::Base, Qt::transparent);
+ m_ui->pTree->setPalette(palette);
const QMap< FontStrings::PanoseKey, QMap<int, QString> >& p(FontStrings::Panose());
QSettings settings;
View
6 src/panosewidget.ui
@@ -28,6 +28,12 @@
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
View
98 src/tagswidget.cpp
@@ -29,13 +29,18 @@ TagsWidget::TagsWidget ( QWidget * parent )
{
setupUi ( this );
- tagsListWidget->setContextMenuPolicy ( Qt::CustomContextMenu );
+ newTagBeingEdited = 0;
connect ( tagsListWidget,SIGNAL ( itemClicked ( QListWidgetItem* ) ),this,SLOT ( slotSwitchCheckState ( QListWidgetItem* ) ) );
connect ( newTagButton,SIGNAL ( clicked ( bool ) ),this,SLOT ( slotNewTag() ) );
-// connect ( newTagName, SIGNAL ( editingFinished() ), this, SLOT ( slotNewTag() ) );
- connect ( tagsListWidget,SIGNAL ( customContextMenuRequested ( const QPoint & ) ), this, SLOT ( slotContextMenu ( QPoint ) ) );
+ connect(removeTagButton, SIGNAL(clicked()), this, SLOT(slotActRemovetag()));
+
+ connect(tagsListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(slotUpdateCurrentTag(QListWidgetItem*,QListWidgetItem*)));
+ connect(tagsListWidget, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotActEditTag(QListWidgetItem*)));
+
+
+// connect ( tagsListWidget,SIGNAL ( customContextMenuRequested ( const QPoint & ) ), this, SLOT ( slotContextMenu ( QPoint ) ) );
}
TagsWidget::~ TagsWidget()
@@ -60,20 +65,29 @@ void TagsWidget::slotSwitchCheckState ( QListWidgetItem * item )
slotFinalize();
}
+void TagsWidget::slotUpdateCurrentTag(QListWidgetItem *current, QListWidgetItem *previous)
+{
+ if(current)
+ currentTag = current->text();
+}
+
void TagsWidget::slotNewTag()
{
-// QString nTag ( newTagName->text() );
-// newTagName->clear();
-// bool ok;
-//// nTag = QInputDialog::getText(this,"Fontmatrix",tr("Add new tag"),QLineEdit::Normal, QString() , &ok );
-// if ( nTag.isEmpty() || FMFontDb::DB()->getTags().contains ( nTag ) )
-// return;
-
-// FMFontDb::DB()->addTagToDB ( nTag );
-// QListWidgetItem *lit = new QListWidgetItem ( nTag );
-// lit->setCheckState ( Qt::Checked );
-// tagsListWidget->addItem ( lit );
-// slotFinalize();
+ if(newTagBeingEdited)
+ return;
+ disconnect(tagsListWidget, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotActEditTag(QListWidgetItem*)));
+ tagsListWidget->setFocus();
+ QString nTag(tr("New Tag"));
+ newTagBeingEdited = new QListWidgetItem(tagsListWidget);
+ tagsListWidget->setCurrentItem(newTagBeingEdited);
+ newTagBeingEdited->setText(nTag);
+ newTagBeingEdited->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
+ newTagBeingEdited->setCheckState(Qt::Unchecked);
+ tagsListWidget->scrollToItem(newTagBeingEdited);
+ FMFontDb::DB()->addTagToDB ( nTag );
+ currentTag = nTag;
+ tagsListWidget->openPersistentEditor(newTagBeingEdited);
+ connect(tagsListWidget, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotActEditTag(QListWidgetItem*)));
}
void TagsWidget::slotFinalize()
@@ -133,29 +147,9 @@ void TagsWidget::prepare ( QList< FontItem * > fonts )
theTaggedFonts = fonts;
bool readOnly ( false );
-// for ( int i ( 0 ); i < theTaggedFonts.count() ; ++i )
-// {
-// if ( theTaggedFonts[i]->isLocked() )
-// {
-// readOnly = true;
-// break;
-// }
-// }
+
tagsListWidget->clear();
-// QString tot;
-// for ( int i=0;i<theTaggedFonts.count();++i )
-// {
-// tot.append ( theTaggedFonts[i]->fancyName() + "\n" );
-// }
-// if ( theTaggedFonts.count() > 1 )
-// {
-// titleLabel->setText ( theTaggedFonts[0]->family() + " (family)" );
-// }
-// else
-// {
-// titleLabel->setText ( theTaggedFonts[0]->fancyName() );
-// }
-// titleLabel->setToolTip ( tot );
+
QStringList tagsList ( FMFontDb::DB()->getTags() );
QString sysTag(typotek::getInstance()->getSysTagName());
@@ -178,6 +172,7 @@ void TagsWidget::prepare ( QList< FontItem * > fonts )
{
lit = new QListWidgetItem ( cur_tag );
+ lit->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
lit->setCheckState ( Qt::Unchecked );
int YesState = 0;
for ( int i=0;i<theTaggedFonts.count();++i )
@@ -262,22 +257,27 @@ void TagsWidget::slotActRemovetag()
}
-void TagsWidget::slotActEditTag()
+void TagsWidget::slotActEditTag(QListWidgetItem * item )
{
-// qDebug()<<"TagsWidget::slotActEditTag";
-// QString fromT(currentTag);
- QString message;
- message = tr ( "Please provide a replacement name for\nthe following tag:") + " " + currentTag ;
- QString nt = QInputDialog::getText ( typotek::getInstance(),
- "Fontmatrix",
- message,
- QLineEdit::Normal,
- currentTag ) ;
- if ( ( nt != currentTag ) && ( !nt.isEmpty() ) )
+ if(!item)
+ return;
+ QString newTag(item->text());
+ if(newTag.isEmpty())
{
- FMFontDb::DB()->editTag ( currentTag, nt );
+ item->setText(currentTag);
+ return;
+ }
+ if ( ( newTag != currentTag ) && (!currentTag.isEmpty()))
+ {
+ FMFontDb::DB()->editTag ( currentTag, newTag );
prepare(theTaggedFonts);
}
+
+ if(newTagBeingEdited == item)
+ {
+ tagsListWidget->closePersistentEditor(newTagBeingEdited);
+ newTagBeingEdited = 0;
+ }
}
View
6 src/tagswidget.h
@@ -27,6 +27,8 @@ class TagsWidget : public QWidget , private Ui::tagsWidget
QList<QAction*> contAction;
QString currentTag;
+
+ QListWidgetItem * newTagBeingEdited;
public:
TagsWidget(QWidget * parent);
@@ -40,10 +42,12 @@ class TagsWidget : public QWidget , private Ui::tagsWidget
void slotSwitchCheckState( QListWidgetItem * item );
void slotNewTag();
void slotFinalize();
+
+ void slotUpdateCurrentTag(QListWidgetItem * current, QListWidgetItem * previous);
void slotContextMenu( QPoint pos );
void slotActRemovetag();
- void slotActEditTag();
+ void slotActEditTag(QListWidgetItem * item );
};

0 comments on commit 351285a

Please sign in to comment.
Something went wrong with that request. Please try again.