Explorar o código

Finish syntax highlighting customization.

git-svn-id: file:///var/svn/tigccpp/trunk@800 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler %!s(int64=18) %!d(string=hai) anos
pai
achega
cf1a85ab6d
Modificáronse 3 ficheiros con 133 adicións e 6 borrados
  1. 23 6
      ktigcc/customstyle.ui
  2. 2 0
      ktigcc/preferencesdlg.ui
  3. 108 0
      ktigcc/preferencesdlg.ui.h

+ 23 - 6
ktigcc/customstyle.ui

@@ -9,7 +9,7 @@
             <x>0</x>
             <y>0</y>
             <width>200</width>
-            <height>210</height>
+            <height>236</height>
         </rect>
     </property>
     <property name="caption">
@@ -84,6 +84,9 @@
                     <property name="name">
                         <cstring>ignoreEndingAfter</cstring>
                     </property>
+                    <property name="maxLength">
+                        <number>1</number>
+                    </property>
                 </widget>
             </hbox>
         </widget>
@@ -98,6 +101,17 @@
                 <string>Alt+W</string>
             </property>
         </widget>
+        <widget class="QCheckBox">
+            <property name="name">
+                <cstring>lineStartOnly</cstring>
+            </property>
+            <property name="text">
+                <string>Only &amp;at beginning of line</string>
+            </property>
+            <property name="accel">
+                <string>Alt+A</string>
+            </property>
+        </widget>
         <widget class="QLayoutWidget">
             <property name="name">
                 <cstring>layout44</cstring>
@@ -143,7 +157,7 @@
             <property name="sizeHint">
                 <size>
                     <width>20</width>
-                    <height>1</height>
+                    <height>16</height>
                 </size>
             </property>
         </spacer>
@@ -189,18 +203,21 @@
 </widget>
 <connections>
     <connection>
-        <sender>okButton</sender>
+        <sender>cancelButton</sender>
         <signal>clicked()</signal>
         <receiver>CustomStyle</receiver>
-        <slot>accept()</slot>
+        <slot>reject()</slot>
     </connection>
     <connection>
-        <sender>cancelButton</sender>
+        <sender>okButton</sender>
         <signal>clicked()</signal>
         <receiver>CustomStyle</receiver>
-        <slot>reject()</slot>
+        <slot>accept()</slot>
     </connection>
 </connections>
+<slots>
+    <slot>newSlot()</slot>
+</slots>
 <pixmapinproject/>
 <layoutdefaults spacing="6" margin="11"/>
 <includehints>

+ 2 - 0
ktigcc/preferencesdlg.ui

@@ -1203,6 +1203,8 @@
     <slot>newStyleButton_clicked()</slot>
     <slot>newListButton_clicked()</slot>
     <slot>editButton_clicked()</slot>
+    <slot>editDialog_colorButton_clicked()</slot>
+    <slot>editDialog_styleButton_clicked()</slot>
 </slots>
 <pixmapinproject/>
 <layoutdefaults spacing="6" margin="11"/>

+ 108 - 0
ktigcc/preferencesdlg.ui.h

@@ -44,10 +44,14 @@
 #include <kcolordialog.h>
 #include <kcombobox.h>
 #include <klistview.h>
+#include <klineedit.h>
+#include <keditlistbox.h>
 #include "ktigcc.h"
 #include "selectstyle.h"
 #include "selectcolors.h"
 #include "colorlistitem.h"
+#include "customstyle.h"
+#include "wordlist.h"
 
 class RenamableKListViewItem : public KListViewItem {
   public:
@@ -527,7 +531,111 @@ void Preferences::newListButton_clicked()
   item->startRename(0);
 }
 
+static QDialog *editDialog;
+static Syn_Style tempStyle;
+static QColor tempColor;
+
 void Preferences::editButton_clicked()
 {
+  QListViewItem *currentItem=syntaxListView->currentItem();
+  if (currentItem && currentItem->rtti()==0x716CC8) {
+    QListViewItem *rootListItem=syntaxListView->firstChild();
+    QListViewItem *customStylesItem=rootListItem->firstChild();
+    QListViewItem *wordListsItem=customStylesItem->nextSibling();
+    if (currentItem->parent()==customStylesItem) {
+      QListViewItem *i;
+      QValueList<Syn_CustomStyle>::Iterator it;
+      for (it=preferences.syn->customStyles.begin(), i=customStylesItem->firstChild();
+           i!=currentItem && it!=preferences.syn->customStyles.end() && i;
+           ++it, i=i->nextSibling());
+      if (it==preferences.syn->customStyles.end() || !i)
+        qWarning("Preferences::editButton_clicked: Invalid item.");
+      else {
+        Syn_CustomStyle &customStyle=*it;
+        CustomStyle customStyleDlg(this);
+        editDialog=&customStyleDlg;
+        customStyleDlg.beginning->setText(customStyle.beginning);
+        customStyleDlg.ending->setText(customStyle.ending=="\n"?"\\n"
+                                       :customStyle.ending);
+        customStyleDlg.ignoreEndingAfter->setText(QString(customStyle.ignoreEndingAfter));
+        customStyleDlg.switchable->setChecked(customStyle.switchable);
+        customStyleDlg.lineStartOnly->setChecked(customStyle.lineStartOnly);
+        tempStyle=customStyle.style;
+        tempColor=customStyle.color;
+        connect(customStyleDlg.styleButton,SIGNAL(clicked()),
+                this,SLOT(editDialog_styleButton_clicked()));
+        connect(customStyleDlg.colorButton,SIGNAL(clicked()),
+                this,SLOT(editDialog_colorButton_clicked()));
+        customStyleDlg.exec();
+        if (customStyleDlg.result()==QDialog::Accepted) {
+          customStyle.beginning=customStyleDlg.beginning->text();
+          customStyle.ending=customStyleDlg.ending->text()=="\\n"?"\n"
+                             :customStyleDlg.ending->text();
+          customStyle.ignoreEndingAfter=customStyleDlg.ignoreEndingAfter->text()[0];
+          customStyle.switchable=customStyleDlg.switchable->isChecked();
+          customStyle.lineStartOnly=customStyleDlg.lineStartOnly->isChecked();
+          customStyle.style=tempStyle;
+          customStyle.color=tempColor;
+        }
+      }
+    } else if (currentItem->parent()==wordListsItem) {
+      QListViewItem *i;
+      QValueList<Syn_WordList>::Iterator it;
+      for (it=preferences.syn->wordLists.begin(), i=wordListsItem->firstChild();
+           i!=currentItem && it!=preferences.syn->wordLists.end() && i;
+           ++it, i=i->nextSibling());
+      if (it==preferences.syn->wordLists.end() || !i)
+        qWarning("Preferences::editButton_clicked: Invalid item.");
+      else {
+        Syn_WordList &wordList=*it;
+        WordList wordListDlg(this);
+        editDialog=&wordListDlg;
+        wordListDlg.wordList->setItems(wordList.list);
+        wordListDlg.caseSensitive->setChecked(wordList.caseSensitive);
+        tempStyle=wordList.style;
+        tempColor=wordList.color;
+        connect(wordListDlg.styleButton,SIGNAL(clicked()),
+                this,SLOT(editDialog_styleButton_clicked()));
+        connect(wordListDlg.colorButton,SIGNAL(clicked()),
+                this,SLOT(editDialog_colorButton_clicked()));
+        wordListDlg.exec();
+        if (wordListDlg.result()==QDialog::Accepted) {
+          wordList.list=wordListDlg.wordList->items();
+          wordList.caseSensitive=wordListDlg.caseSensitive->isChecked();
+          wordList.style=tempStyle;
+          wordList.color=tempColor;
+        }
+      }
+    } else qWarning("Preferences::editButton_clicked: Invalid parent.");
+  }
+}
+
+void Preferences::editDialog_colorButton_clicked()
+{
+  QColor color=tempColor;
+  if (KColorDialog::getColor(color,QColor(),editDialog)==KColorDialog::Accepted)
+    tempColor=color;
+}
 
+void Preferences::editDialog_styleButton_clicked()
+{
+  SelectStyle selectStyle(this);
+  selectStyle.customStyle->setChecked(!!(tempStyle&SYNS_CUSTOM));
+  if (tempStyle&SYNS_CUSTOM) {
+    selectStyle.boldChk->setChecked(!!(tempStyle&SYNS_BOLD));
+    selectStyle.underlineChk->setChecked(!!(tempStyle&SYNS_UNDERLINE));
+    selectStyle.italicChk->setChecked(!!(tempStyle&SYNS_ITALIC));
+    selectStyle.strikeoutChk->setChecked(!!(tempStyle&SYNS_STRIKEOUT));
+  }
+  selectStyle.exec();
+  if (selectStyle.result()==QDialog::Accepted) {
+    tempStyle=0;
+    if (selectStyle.customStyle->isChecked()) {
+      tempStyle|=SYNS_CUSTOM;
+      if (selectStyle.boldChk->isChecked()) tempStyle|=SYNS_BOLD;
+      if (selectStyle.underlineChk->isChecked()) tempStyle|=SYNS_UNDERLINE;
+      if (selectStyle.italicChk->isChecked()) tempStyle|=SYNS_ITALIC;
+      if (selectStyle.strikeoutChk->isChecked()) tempStyle|=SYNS_STRIKEOUT;
+    }
+  }
 }