Active Topics

 


Reply
Thread Tools
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#101
Originally Posted by Diph View Post
I haven't used Designer myself, but I think it should make labels etc. automatically translatable.

Did you try steps from here: http://doc.qt.nokia.com/qt-maemo-4.6...e-translations
Noup, but will try it
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#102
Okay.. translation thing is almost in order.

Then new questions / things I cannot achieve with my (or google's) knowledge:

I currently have this function to read directory names and then put them in QStringList:
Code:
void MainWindow::readdirs()
{
    QDir colors("/opt/plastic-schemes");
    QStringList colorstobox = colors.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::DirsFirst);
    ui->Color->addItems(colorstobox);
}
How can I filter out unwanted directories? If I wanted to filter out directory called "Emacs", how would I do that? I couldn't find any info about excluding directories when using QDir :-(

In terminal I would just type:
ls | grep -v Emacs
--------------------------------------

Then question #2 which is more complicated:
How could I parse html color codes from text file formatted like this and then put the parsed results in separate QStrings?:
Code:
DefaultTextColor=#ced0d5
SecondaryTextColor=#ffbb45
ActiveTextColor=#ffbb45
DisabledTextColor=#8e8e8e
PaintedTextColor=#1c1c1c

ReversedTextColor=#141414
ReversedSecondaryTextColor=#d29e00
ReversedActiveTextColor=#d29e00
ReversedDisabledTextColor=#c5c5c5
ReversedPaintedTextColor=#ffffff
The QString should also be given name from that file (ie. ReversedPaintedTextColor).

That's it this time :-D

Any good googling hits would be appreciated!
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
Posts: 180 | Thanked: 76 times | Joined on May 2010
#103
#1: I would just read all and then call colorstobox.filter() with appropriate regular expression.

#2: Read file line by line and use QString::split to split from "=". Then put keys and values to QHash<QString,QString> if color names are unique.
 

The Following User Says Thank You to Diph For This Useful Post:
CepiPerez's Avatar
Posts: 1,023 | Thanked: 4,421 times | Joined on Feb 2010 @ Argentina
#104
#1:
void MainWindow::readdirs()
{
QDir colors("/opt/plastic-schemes");
QStringList colorstobox = colors.entryList(QDir:irs | QDir::NoDotAndDotDot);

for ( int i=0; i < colorstobox.count(); ++i )
if ( colorstobox[i] != "Emacs" ) ui->Color->addItems(colorstobox);
}
 

The Following User Says Thank You to CepiPerez For This Useful Post:
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#105
Originally Posted by CepiPerez View Post
#1:
void MainWindow::readdirs()
{
QDir colors("/opt/plastic-schemes");
QStringList colorstobox = colors.entryList(QDir:irs | QDir::NoDotAndDotDot);

for ( int i=0; i < colorstobox.count(); ++i )
if ( colorstobox[i] != "Emacs" ) ui->Color->addItems(colorstobox);
}
Aah, ofcourse! Why didn't I figure out to use loop and if

Thx.
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
Posts: 180 | Thanked: 76 times | Joined on May 2010
#106
That loop calls ui->Color->addItems(QStringList) for every item that is not "Emacs".

Either change the method or use temp variable where you store "non-Emacs" entries and then call addItems().
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#107
Originally Posted by Diph View Post
Either change the method or use temp variable where you store "non-Emacs" entries and then call addItems().
True. Temp variable sounds like an option. Will give it a go.
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#108
Okay.. the question #1 is now solved and unwanted dirs are filtered out. I'm still stuck with question #2. I just don't understand the documentation good anough how to turn this:
Code:
DefaultTextColor=#ced0d5
into this:
Code:
QString DefaultTextColor;
DefaultTextColor = "#ced0d5";
I'm doing the file reading like this.
Code:
QFile file(/etc/hildon/theme/colors.config);
if (!file.open (IO_ReadOnly))
   // didn't work
QTextStream stream ( &file );
QString line;
while( !stream.eof() ) {
     line = stream.readLine();
     <process your line and repeat>
}
file.close();
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
Posts: 180 | Thanked: 76 times | Joined on May 2010
#109
Store the items in QHash. Then you can access items by key: QHash::value(const Key & key)

Code:
QFile file(/etc/hildon/theme/colors.config);
if (!file.open (IO_ReadOnly))
   // didn't work
QTextStream stream ( &file );
QString line;
QHash<QString, QString> variables;
while( !stream.eof() ) {
     line = stream.readLine();
     //Split
     QStringList splittedLine = line.split("=");
     //Maybe add some checks here (splittedLine.count == 2 etc.)
     variables.insert(splittedLine.at(0), splittedLine.at(1)); 
}
file.close();

Last edited by Diph; 2010-09-21 at 08:59.
 

The Following User Says Thank You to Diph For This Useful Post:
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#110
Thanks for all help so far. I've managed to get things working pretty nice. Now I have a simple question; how can I send a QString from one slot to another? I'm pretty hopeless with all connect this and that to here and there -stuff, so please help me out :-D

What I mean is that when program is launched, I store some info into QStrings like this:
Code:
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    progress("Setting up the theme, please wait...", "Abort", 0, 0, this),
    colors()
{
    ui->setupUi(this);
    ui->scrollArea->setWidget(ui->widget);
    readdirs();
    QString oldfont1 = ui->font1->text();
    QString oldfont2 = ui->font2->text();
    QString oldfont3 = ui->font3->text();
    QString oldfont4 = ui->font4->text();
//    readSettings();
}
And I would like to pass those QStrings into slot when a button is clicked:
Code:
void MainWindow::on_pushButton_clicked()
{

}
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 

The Following User Says Thank You to d-iivil For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 10:04.