~ubuntu-branches/ubuntu/maverick/luckybackup/maverick

« back to all changes in this revision

Viewing changes to src/textDialog.cpp

  • Committer: Andrew Starr-Bochicchio
  • Date: 2010-05-26 04:01:25 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: a.starr.b@gmail.com-20100526040125-9fjy5y0jyzlrbkny
Tags: 0.4.0-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
 - Use gksu to launch in superuser mode as Ubuntu
   doesn't use su-to-root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
//===============================================================================================================================
5
5
//===============================================================================================================================
6
6
//     This file is part of "luckyBackup" project
7
 
//     Copyright 2008-2009, Loukas Avgeriou
 
7
//     Copyright 2008-2010, Loukas Avgeriou
8
8
//     luckyBackup is distributed under the terms of the GNU General Public License
9
9
//     luckyBackup is free software: you can redistribute it and/or modify
10
10
//     it under the terms of the GNU General Public License as published by
23
23
// project version      : Please see "main.cpp" for project version
24
24
 
25
25
// developer            : luckyb 
26
 
// last modified        : 12 Dec 2009
 
26
// last modified        : 16 Apr 2010
27
27
//===============================================================================================================================
28
28
//===============================================================================================================================
29
29
 
43
43
 
44
44
        GoOn = 0;
45
45
        Type = type;
 
46
        TextPassed = ReplaceInput;
46
47
        if (type == "NewProfile")
47
48
        {
48
49
                uiT.label_message       -> setText(tr("Enter the name of the new profile :"));
82
83
                uiT.label_message       -> setText(tr("You have selected to \"Backup the contents of the source directory\"<br>together with the \"delete files on the destination\" option") +"<br><br>" + tr("BEWARE, if your intention is NOT to clone source to destination !!") +"<br><br>" + 
83
84
                                tr("Are you sure you wish to proceed ??") + "<br><br>");
84
85
        }
 
86
        if (type == "ValidateDialog")
 
87
        {
 
88
                uiT.lineEdit_userInput  -> setVisible(FALSE);
 
89
                uiT.label_warning -> setVisible(TRUE);
 
90
                uiT.label_warning -> setPixmap(QPixmap(":/luckyPrefix/validate.png"));
 
91
                uiT.pushButton_cancel -> setText(tr("Copy command to clipboard"));
 
92
                uiT.pushButton_cancel -> setIcon(QIcon(":/luckyPrefix/copy.png"));
 
93
                uiT.label_message       -> setText(ReplaceInput);
 
94
        }
 
95
        if (type == "ViewCurrentCrontab")
 
96
        {
 
97
                this -> resize(640, 480);
 
98
                uiT.lineEdit_userInput  -> setVisible(FALSE);
 
99
                uiT.pushButton_cancel -> setVisible(FALSE);
 
100
                uiT.label_message       -> setText(ReplaceInput);
 
101
        }
85
102
}
86
103
// SLOTS-------------------------------------------------------------------------------------
87
104
// --------------------------------okay pressed------------------------------------------------
121
138
void textDialog::cancel()
122
139
{
123
140
        //GoOn == 0
124
 
        close();
 
141
        if (Type == "ValidateDialog")
 
142
        {
 
143
                QString source, dest, Command_Clipboard;
 
144
        
 
145
                //copy command to clipboard             
 
146
                TextPassed = TextPassed.right(TextPassed.size()-TextPassed.indexOf("<font color=red>"));        //remove all irrelevant text
 
147
                source = TextPassed.right(TextPassed.size()-TextPassed.indexOf("<font color=magenta>"));        //copy source & dest inside QString source
 
148
                TextPassed.remove(source);                                                                                                                                      //remove source & dest from whole command
 
149
                dest = source.right(source.size()-source.lastIndexOf("<font color=magenta>"));                          //copy dest inside QString dest
 
150
                source.remove(dest);                                                                                                                                            //remove dest from source
 
151
 
 
152
                source.remove("<font color=magenta>",Qt::CaseSensitive);
 
153
                source.remove("</font>",Qt::CaseSensitive);
 
154
                source.remove("<br>",Qt::CaseSensitive);
 
155
                if (source.endsWith(" "))
 
156
                        source.chop(1);
 
157
                source.replace(" ","\\ ");                                                                                                                                      //replace whitespaces with " \"
 
158
 
 
159
                dest.remove("<font color=magenta>",Qt::CaseSensitive);
 
160
                dest.remove("</font>",Qt::CaseSensitive);
 
161
                dest.remove("<br>",Qt::CaseSensitive);
 
162
                dest.replace(" ","\\ ");        
 
163
                
 
164
                Command_Clipboard = TextPassed + source + " " + dest;
 
165
                Command_Clipboard.remove("<font color=red>",Qt::CaseSensitive);
 
166
                Command_Clipboard.remove("<font color=blue>",Qt::CaseSensitive);
 
167
                Command_Clipboard.remove("</font>",Qt::CaseSensitive);
 
168
                Command_Clipboard.remove("<br>",Qt::CaseSensitive);
 
169
                
 
170
                QClipboard *clipboard = QApplication::clipboard();
 
171
                clipboard->setText(Command_Clipboard);
 
172
        }
 
173
        else
 
174
                close();
125
175
}
126
176
 
127
177
void textDialog::closeEvent(QCloseEvent *event)