TECHNOLOGY PREVIEW LICENSE AGREEMENT For individuals and/or legal entities resident in the Americas (North America, Central America and South America), the applicable licensing terms are specified under the heading "Technology Preview License Agreement: The Americas". For individuals and/or legal entities not resident in The Americas, the applicable licensing terms are specified under the heading "Technology Preview License Agreement: Rest of the World". TECHNOLOGY PREVIEW LICENSE AGREEMENT: The Americas Agreement version 2.3 This Technology Preview License Agreement ("Agreement") is a legal agreement between Nokia Inc. ("Nokia"), with its registered office at 6021 Connection Drive, Irving, TX 75039, U.S.A. and you (either an individual or a legal entity) ("Licensee") for the Licensed Software (as defined below). 1. DEFINITIONS "Affiliate" of a Party shall mean an entity (i) which is directly or indirectly controlling such Party; (ii) which is under the same direct or indirect ownership or control as such Party; or (iii) which is directly or indirectly owned or controlled by such Party. For these purposes, an entity shall be treated as being controlled by another if that other entity has fifty percent (50 %) or more of the votes in such entity, is able to direct its affairs and/or to control the composition of its board of directors or equivalent body. "Term" shall mean the period of time six (6) months from the later of (a) the Effective Date; or (b) the date the Licensed Software was initially delivered to Licensee by Nokia. If no specific Effective Date is set forth in the Agreement, the Effective Date shall be deemed to be the date the Licensed Software was initially delivered to Licensee. "Licensed Software" shall mean the computer software, "online" or electronic documentation, associated media and printed materials, including the source code, example programs and the documentation delivered by Nokia to Licensee in conjunction with this Agreement. "Party" or "Parties" shall mean Licensee and/or Nokia. 2. OWNERSHIP The Licensed Software is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. The Licensed Software is licensed, not sold. If Licensee provides any findings, proposals, suggestions or other feedback ("Feedback") to Nokia regarding the Licensed Software, Nokia shall own all right, title and interest including the intellectual property rights in and to such Feedback, excluding however any existing patent rights of Licensee. To the extent Licensee owns or controls any patents for such Feedback Licensee hereby grants to Nokia and its Affiliates, a worldwide, perpetual, non-transferable, sublicensable, royalty-free license to (i) use, copy and modify Feedback and to create derivative works thereof, (ii) to make (and have made), use, import, sell, offer for sale, lease, dispose, offer for disposal or otherwise exploit any products or services of Nokia containing Feedback,, and (iii) sublicense all the foregoing rights to third party licensees and customers of Nokia and/or its Affiliates. 3. VALIDITY OF THE AGREEMENT By installing, copying, or otherwise using the Licensed Software, Licensee agrees to be bound by the terms of this Agreement. If Licensee does not agree to the terms of this Agreement, Licensee may not install, copy, or otherwise use the Licensed Software. Upon Licensee's acceptance of the terms and conditions of this Agreement, Nokia grants Licensee the right to use the Licensed Software in the manner provided below. 4. LICENSES 4.1 Using and Copying Nokia grants to Licensee a non-exclusive, non-transferable, time-limited license to use and copy the Licensed Software for sole purpose of evaluating and testing the Licensed Software during the Term. Licensee may install copies of the Licensed Software on an unlimited number of computers provided that (a) if an individual, only such individual; or (b) if a legal entity only its employees; use the Licensed Software for the authorized purposes. 4.2 No Distribution or Modifications Licensee may not disclose, modify, sell, market, commercialise, distribute, loan, rent, lease, or license the Licensed Software or any copy of it or use the Licensed Software for any purpose that is not expressly granted in this Section 4. Licensee may not alter or remove any details of ownership, copyright, trademark or other property right connected with the Licensed Software. Licensee may not distribute any software statically or dynamically linked with the Licensed Software. 4.3 No Technical Support Nokia has no obligation to furnish Licensee with any technical support whatsoever. Any such support is subject to separate agreement between the Parties. 5. PRE-RELEASE CODE The Licensed Software contains pre-release code that is not at the level of performance and compatibility of a final, generally available, product offering. The Licensed Software may not operate correctly and may be substantially modified prior to the first commercial product release, if any. Nokia is not obligated to make this or any later version of the Licensed Software commercially available. The License Software is "Not for Commercial Use" and may only be used for the purposes described in Section 4. The Licensed Software may not be used in a live operating environment where it may be relied upon to perform in the same manner as a commercially released product or with data that has not been sufficiently backed up. 6. THIRD PARTY SOFTWARE The Licensed Software may provide links to third party libraries or code (collectively "Third Party Software") to implement various functions. Third Party Software does not comprise part of the Licensed Software. In some cases, access to Third Party Software may be included along with the Licensed Software delivery as a convenience for development and testing only. Such source code and libraries may be listed in the ".../src/3rdparty" source tree delivered with the Licensed Software or documented in the Licensed Software where the Third Party Software is used, as may be amended from time to time, do not comprise the Licensed Software. Licensee acknowledges (1) that some part of Third Party Software may require additional licensing of copyright and patents from the owners of such, and (2) that distribution of any of the Licensed Software referencing any portion of a Third Party Software may require appropriate licensing from such third parties. 7. LIMITED WARRANTY AND WARRANTY DISCLAIMER The Licensed Software is licensed to Licensee "as is". To the maximum extent permitted by applicable law, Nokia on behalf of itself and its suppliers, disclaims all warranties and conditions, either express or implied, including, but not limited to, implied warranties of merchantability, fitness for a particular purpose, title and non-infringement with regard to the Licensed Software. 8. LIMITATION OF LIABILITY If, Nokia's warranty disclaimer notwithstanding, Nokia is held liable to Licensee, whether in contract, tort or any other legal theory, based on the Licensed Software, Nokia's entire liability to Licensee and Licensee's exclusive remedy shall be, at Nokia's option, either (A) return of the price Licensee paid for the Licensed Software, or (B) repair or replacement of the Licensed Software, provided Licensee returns to Nokia all copies of the Licensed Software as originally delivered to Licensee. Nokia shall not under any circumstances be liable to Licensee based on failure of the Licensed Software if the failure resulted from accident, abuse or misapplication, nor shall Nokia under any circumstances be liable for special damages, punitive or exemplary damages, damages for loss of profits or interruption of business or for loss or corruption of data. Any award of damages from Nokia to Licensee shall not exceed the total amount Licensee has paid to Nokia in connection with this Agreement. 9. CONFIDENTIALITY Each party acknowledges that during the Term of this Agreement it shall have access to information about the other party's business, business methods, business plans, customers, business relations, technology, and other information, including the terms of this Agreement, that is confidential and of great value to the other party, and the value of which would be significantly reduced if disclosed to third parties (the "Confidential Information"). Accordingly, when a party (the "Receiving Party") receives Confidential Information from another party (the "Disclosing Party"), the Receiving Party shall, and shall obligate its employees and agents and employees and agents of its Affiliates to: (i) maintain the Confidential Information in strict confidence; (ii) not disclose the Confidential Information to a third party without the Disclosing Party's prior written approval; and (iii) not, directly or indirectly, use the Confidential Information for any purpose other than for exercising its rights and fulfilling its responsibilities pursuant to this Agreement. Each party shall take reasonable measures to protect the Confidential Information of the other party, which measures shall not be less than the measures taken by such party to protect its own confidential and proprietary information. "Confidential Information" shall not include information that (a) is or becomes generally known to the public through no act or omission of the Receiving Party; (b) was in the Receiving Party's lawful possession prior to the disclosure hereunder and was not subject to limitations on disclosure or use; (c) is developed by the Receiving Party without access to the Confidential Information of the Disclosing Party or by persons who have not had access to the Confidential Information of the Disclosing Party as proven by the written records of the Receiving Party; (d) is lawfully disclosed to the Receiving Party without restrictions, by a third party not under an obligation of confidentiality; or (e) the Receiving Party is legally compelled to disclose the information, in which case the Receiving Party shall assert the privileged and confidential nature of the information and cooperate fully with the Disclosing Party to protect against and prevent disclosure of any Confidential Information and to limit the scope of disclosure and the dissemination of disclosed Confidential Information by all legally available means. The obligations of the Receiving Party under this Section shall continue during the Initial Term and for a period of five (5) years after expiration or termination of this Agreement. To the extent that the terms of the Non-Disclosure Agreement between Nokia and Licensee conflict with the terms of this Section 8, this Section 8 shall be controlling over the terms of the Non-Disclosure Agreement. 10. GENERAL PROVISIONS 10.1 No Assignment Licensee shall not be entitled to assign or transfer all or any of its rights, benefits and obligations under this Agreement without the prior written consent of Nokia, which shall not be unreasonably withheld. 10.2 Termination Nokia may terminate the Agreement at any time immediately upon written notice by Nokia to Licensee if Licensee breaches this Agreement. Upon termination of this Agreement, Licensee shall return to Nokia all copies of Licensed Software that were supplied by Nokia. All other copies of Licensed Software in the possession or control of Licensee must be erased or destroyed. An officer of Licensee must promptly deliver to Nokia a written confirmation that this has occurred. 10.3 Surviving Sections Any terms and conditions that by their nature or otherwise reasonably should survive a cancellation or termination of this Agreement shall also be deemed to survive. Such terms and conditions include, but are not limited to the following Sections: 2, 5, 6, 7, 8, 9, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, and 10.8 of this Agreement. 10.4 Entire Agreement This Agreement constitutes the complete agreement between the parties and supersedes all prior or contemporaneous discussions, representations, and proposals, written or oral, with respect to the subject matters discussed herein, with the exception of the non-disclosure agreement executed by the parties in connection with this Agreement ("Non-Disclosure Agreement"), if any, shall be subject to Section 8. No modification of this Agreement shall be effective unless contained in a writing executed by an authorized representative of each party. No term or condition contained in Licensee's purchase order shall apply unless expressly accepted by Nokia in writing. If any provision of the Agreement is found void or unenforceable, the remainder shall remain valid and enforceable according to its terms. If any remedy provided is determined to have failed for its essential purpose, all limitations of liability and exclusions of damages set forth in this Agreement shall remain in effect. 10.5 Export Control Licensee acknowledges that the Licensed Software may be subject to export control restrictions of various countries. Licensee shall fully comply with all applicable export license restrictions and requirements as well as with all laws and regulations relating to the importation of the Licensed Software and shall procure all necessary governmental authorizations, including without limitation, all necessary licenses, approvals, permissions or consents, where necessary for the re-exportation of the Licensed Software., 10.6 Governing Law and Legal Venue This Agreement shall be governed by and construed in accordance with the federal laws of the United States of America and the internal laws of the State of New York without given effect to any choice of law rule that would result in the application of the laws of any other jurisdiction. The United Nations Convention on Contracts for the International Sale of Goods (CISG) shall not apply. Each Party (a) hereby irrevocably submits itself to and consents to the jurisdiction of the United States District Court for the Southern District of New York (or if such court lacks jurisdiction, the state courts of the State of New York) for the purposes of any action, claim, suit or proceeding between the Parties in connection with any controversy, claim, or dispute arising out of or relating to this Agreement; and (b) hereby waives, and agrees not to assert by way of motion, as a defense or otherwise, in any such action, claim, suit or proceeding, any claim that is not personally subject to the jurisdiction of such court(s), that the action, claim, suit or proceeding is brought in an inconvenient forum or that the venue of the action, claim, suit or proceeding is improper. Notwithstanding the foregoing, nothing in this Section 9.6 is intended to, or shall be deemed to, constitute a submission or consent to, or selection of, jurisdiction, forum or venue for any action for patent infringement, whether or not such action relates to this Agreement. 10.7 No Implied License There are no implied licenses or other implied rights granted under this Agreement, and all rights, save for those expressly granted hereunder, shall remain with Nokia and its licensors. In addition, no licenses or immunities are granted to the combination of the Licensed Software with any other software or hardware not delivered by Nokia under this Agreement. 10.8 Government End Users A "U.S. Government End User" shall mean any agency or entity of the government of the United States. The following shall apply if Licensee is a U.S. Government End User. The Licensed Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire the Licensed Software with only those rights set forth herein. The Licensed Software (including related documentation) is provided to U.S. Government End Users: (a) only as a commercial end item; and (b) only pursuant to this Agreement. TECHNOLOGY PREVIEW LICENSE AGREEMENT: Rest of the World Agreement version 2.3 This Technology Preview License Agreement ("Agreement") is a legal agreement between Nokia Corporation ("Nokia"), with its registered office at Keilalahdentie 4, 02150 Espoo, Finland and you (either an individual or a legal entity) ("Licensee") for the Licensed Software (as defined below). 1. DEFINITIONS "Affiliate" of a Party shall mean an entity (i) which is directly or indirectly controlling such Party; (ii) which is under the same direct or indirect ownership or control as such Party; or (iii) which is directly or indirectly owned or controlled by such Party. For these purposes, an entity shall be treated as being controlled by another if that other entity has fifty percent (50 %) or more of the votes in such entity, is able to direct its affairs and/or to control the composition of its board of directors or equivalent body. "Term" shall mean the period of time six (6) months from the later of (a) the Effective Date; or (b) the date the Licensed Software was initially delivered to Licensee by Nokia. If no specific Effective Date is set forth in the Agreement, the Effective Date shall be deemed to be the date the Licensed Software was initially delivered to Licensee. "Licensed Software" shall mean the computer software, "online" or electronic documentation, associated media and printed materials, including the source code, example programs and the documentation delivered by Nokia to Licensee in conjunction with this Agreement. "Party" or "Parties" shall mean Licensee and/or Nokia. 2. OWNERSHIP The Licensed Software is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. The Licensed Software is licensed, not sold. If Licensee provides any findings, proposals, suggestions or other feedback ("Feedback") to Nokia regarding the Licensed Software, Nokia shall own all right, title and interest including the intellectual property rights in and to such Feedback, excluding however any existing patent rights of Licensee. To the extent Licensee owns or controls any patents for such Feedback Licensee hereby grants to Nokia and its Affiliates, a worldwide, perpetual, non-transferable, sublicensable, royalty-free license to (i) use, copy and modify Feedback and to create derivative works thereof, (ii) to make (and have made), use, import, sell, offer for sale, lease, dispose, offer for disposal or otherwise exploit any products or services of Nokia containing Feedback,, and (iii) sublicense all the foregoing rights to third party licensees and customers of Nokia and/or its Affiliates. 3. VALIDITY OF THE AGREEMENT By installing, copying, or otherwise using the Licensed Software, Licensee agrees to be bound by the terms of this Agreement. If Licensee does not agree to the terms of this Agreement, Licensee may not install, copy, or otherwise use the Licensed Software. Upon Licensee's acceptance of the terms and conditions of this Agreement, Nokia grants Licensee the right to use the Licensed Software in the manner provided below. 4. LICENSES 4.1 Using and Copying Nokia grants to Licensee a non-exclusive, non-transferable, time-limited license to use and copy the Licensed Software for sole purpose of evaluating and testing the Licensed Software during the Term. Licensee may install copies of the Licensed Software on an unlimited number of computers provided that (a) if an individual, only such individual; or (b) if a legal entity only its employees; use the Licensed Software for the authorized purposes. 4.2 No Distribution or Modifications Licensee may not disclose, modify, sell, market, commercialise, distribute, loan, rent, lease, or license the Licensed Software or any copy of it or use the Licensed Software for any purpose that is not expressly granted in this Section 4. Licensee may not alter or remove any details of ownership, copyright, trademark or other property right connected with the Licensed Software. Licensee may not distribute any software statically or dynamically linked with the Licensed Software. 4.3 No Technical Support Nokia has no obligation to furnish Licensee with any technical support whatsoever. Any such support is subject to separate agreement between the Parties. 5. PRE-RELEASE CODE The Licensed Software contains pre-release code that is not at the level of performance and compatibility of a final, generally available, product offering. The Licensed Software may not operate correctly and may be substantially modified prior to the first commercial product release, if any. Nokia is not obligated to make this or any later version of the Licensed Software commercially available. The License Software is "Not for Commercial Use" and may only be used for the purposes described in Section 4. The Licensed Software may not be used in a live operating environment where it may be relied upon to perform in the same manner as a commercially released product or with data that has not been sufficiently backed up. 6. THIRD PARTY SOFTWARE The Licensed Software may provide links to third party libraries or code (collectively "Third Party Software") to implement various functions. Third Party Software does not comprise part of the Licensed Software. In some cases, access to Third Party Software may be included along with the Licensed Software delivery as a convenience for development and testing only. Such source code and libraries may be listed in the ".../src/3rdparty" source tree delivered with the Licensed Software or documented in the Licensed Software where the Third Party Software is used, as may be amended from time to time, do not comprise the Licensed Software. Licensee acknowledges (1) that some part of Third Party Software may require additional licensing of copyright and patents from the owners of such, and (2) that distribution of any of the Licensed Software referencing any portion of a Third Party Software may require appropriate licensing from such third parties. 7. LIMITED WARRANTY AND WARRANTY DISCLAIMER The Licensed Software is licensed to Licensee "as is". To the maximum extent permitted by applicable law, Nokia on behalf of itself and its suppliers, disclaims all warranties and conditions, either express or implied, including, but not limited to, implied warranties of merchantability, fitness for a particular purpose, title and non-infringement with regard to the Licensed Software. 8. LIMITATION OF LIABILITY If, Nokia's warranty disclaimer notwithstanding, Nokia is held liable to Licensee, whether in contract, tort or any other legal theory, based on the Licensed Software, Nokia's entire liability to Licensee and Licensee's exclusive remedy shall be, at Nokia's option, either (A) return of the price Licensee paid for the Licensed Software, or (B) repair or replacement of the Licensed Software, provided Licensee returns to Nokia all copies of the Licensed Software as originally delivered to Licensee. Nokia shall not under any circumstances be liable to Licensee based on failure of the Licensed Software if the failure resulted from accident, abuse or misapplication, nor shall Nokia under any circumstances be liable for special damages, punitive or exemplary damages, damages for loss of profits or interruption of business or for loss or corruption of data. Any award of damages from Nokia to Licensee shall not exceed the total amount Licensee has paid to Nokia in connection with this Agreement. 9. CONFIDENTIALITY Each party acknowledges that during the Term of this Agreement it shall have access to information about the other party's business, business methods, business plans, customers, business relations, technology, and other information, including the terms of this Agreement, that is confidential and of great value to the other party, and the value of which would be significantly reduced if disclosed to third parties (the "Confidential Information"). Accordingly, when a party (the "Receiving Party") receives Confidential Information from another party (the "Disclosing Party"), the Receiving Party shall, and shall obligate its employees and agents and employees and agents of its Affiliates to: (i) maintain the Confidential Information in strict confidence; (ii) not disclose the Confidential Information to a third party without the Disclosing Party's prior written approval; and (iii) not, directly or indirectly, use the Confidential Information for any purpose other than for exercising its rights and fulfilling its responsibilities pursuant to this Agreement. Each party shall take reasonable measures to protect the Confidential Information of the other party, which measures shall not be less than the measures taken by such party to protect its own confidential and proprietary information. "Confidential Information" shall not include information that (a) is or becomes generally known to the public through no act or omission of the Receiving Party; (b) was in the Receiving Party's lawful possession prior to the disclosure hereunder and was not subject to limitations on disclosure or use; (c) is developed by the Receiving Party without access to the Confidential Information of the Disclosing Party or by persons who have not had access to the Confidential Information of the Disclosing Party as proven by the written records of the Receiving Party; (d) is lawfully disclosed to the Receiving Party without restrictions, by a third party not under an obligation of confidentiality; or (e) the Receiving Party is legally compelled to disclose the information, in which case the Receiving Party shall assert the privileged and confidential nature of the information and cooperate fully with the Disclosing Party to protect against and prevent disclosure of any Confidential Information and to limit the scope of disclosure and the dissemination of disclosed Confidential Information by all legally available means. The obligations of the Receiving Party under this Section shall continue during the Initial Term and for a period of five (5) years after expiration or termination of this Agreement. To the extent that the terms of the Non-Disclosure Agreement between Nokia and Licensee conflict with the terms of this Section 8, this Section 8 shall be controlling over the terms of the Non-Disclosure Agreement. 10. GENERAL PROVISIONS 10.1 No Assignment Licensee shall not be entitled to assign or transfer all or any of its rights, benefits and obligations under this Agreement without the prior written consent of Nokia, which shall not be unreasonably withheld. 10.2 Termination Nokia may terminate the Agreement at any time immediately upon written notice by Nokia to Licensee if Licensee breaches this Agreement. Upon termination of this Agreement, Licensee shall return to Nokia all copies of Licensed Software that were supplied by Nokia. All other copies of Licensed Software in the possession or control of Licensee must be erased or destroyed. An officer of Licensee must promptly deliver to Nokia a written confirmation that this has occurred. 10.3 Surviving Sections Any terms and conditions that by their nature or otherwise reasonably should survive a cancellation or termination of this Agreement shall also be deemed to survive. Such terms and conditions include, but are not limited to the following Sections: 2, 5, 6, 7, 8, 9, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, and 10.8 of this Agreement. 10.4 Entire Agreement This Agreement constitutes the complete agreement between the parties and supersedes all prior or contemporaneous discussions, representations, and proposals, written or oral, with respect to the subject matters discussed herein, with the exception of the non-disclosure agreement executed by the parties in connection with this Agreement ("Non-Disclosure Agreement"), if any, shall be subject to Section 8. No modification of this Agreement shall be effective unless contained in a writing executed by an authorized representative of each party. No term or condition contained in Licensee's purchase order shall apply unless expressly accepted by Nokia in writing. If any provision of the Agreement is found void or unenforceable, the remainder shall remain valid and enforceable according to its terms. If any remedy provided is determined to have failed for its essential purpose, all limitations of liability and exclusions of damages set forth in this Agreement shall remain in effect. 10.5 Export Control Licensee acknowledges that the Licensed Software may be subject to export control restrictions of various countries. Licensee shall fully comply with all applicable export license restrictions and requirements as well as with all laws and regulations relating to the importation of the Licensed Software and shall procure all necessary governmental authorizations, including without limitation, all necessary licenses, approvals, permissions or consents, where necessary for the re-exportation of the Licensed Software., 10.6 Governing Law and Legal Venue This Agreement shall be construed and interpreted in accordance with the laws of Finland, excluding its choice of law provisions. Any disputes arising out of or relating to this Agreement shall be resolved in arbitration under the Rules of Arbitration of the Chamber of Commerce of Helsinki, Finland. The arbitration tribunal shall consist of one (1), or if either Party so requires, of three (3), arbitrators. The award shall be final and binding and enforceable in any court of competent jurisdiction. The arbitration shall be held in Helsinki, Finland and the process shall be conducted in the English language. 10.7 No Implied License There are no implied licenses or other implied rights granted under this Agreement, and all rights, save for those expressly granted hereunder, shall remain with Nokia and its licensors. In addition, no licenses or immunities are granted to the combination of the Licensed Software with any other software or hardware not delivered by Nokia under this Agreement. 10.8 Government End Users A "U.S. Government End User" shall mean any agency or entity of the government of the United States. The following shall apply if Licensee is a U.S. Government End User. The Licensed Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire the Licensed Software with only those rights set forth herein. The Licensed Software (including related documentation) is provided to U.S. Government End Users: (a) only as a commercial end item; and (b) only pursuant to this Agreement. nu(fileMenu); - - connect(playButton, SIGNAL(clicked()), this, SLOT(playPause())); - connect(forwardButton, SIGNAL(clicked()), this, SLOT(forward())); - //connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); - connect(settingsAction, SIGNAL(triggered(bool)), this, SLOT(showSettingsDialog())); - connect(openUrlAction, SIGNAL(triggered(bool)), this, SLOT(openUrl())); - connect(openFileAction, SIGNAL(triggered(bool)), this, SLOT(openFile())); - - connect(m_videoWidget, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); - connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); - connect(&m_MediaObject, SIGNAL(metaDataChanged()), this, SLOT(updateInfo())); - connect(&m_MediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateTime())); - connect(&m_MediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime())); - connect(&m_MediaObject, SIGNAL(finished()), this, SLOT(finished())); - connect(&m_MediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(stateChanged(Phonon::State, Phonon::State))); - connect(&m_MediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int))); - - rewindButton->setEnabled(false); - playButton->setEnabled(false); - setAcceptDrops(true); - - m_audioOutputPath = Phonon::createPath(&m_MediaObject, &m_AudioOutput); - Phonon::createPath(&m_MediaObject, m_videoWidget); - - if (!filePath.isEmpty()) - setFile(filePath); - resize(minimumSizeHint()); -} - -void MediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) -{ - Q_UNUSED(oldstate); - - if (oldstate == Phonon::LoadingState) { - m_videoWindow.setVisible(m_MediaObject.hasVideo()); - info->setVisible(!m_MediaObject.hasVideo()); - QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint()); - QRect newVideoRect = QApplication::desktop()->screenGeometry().intersected(videoHintRect); - if (!m_hasSmallScreen) { - if (m_MediaObject.hasVideo()) { - // Flush event que so that sizeHint takes the - // recently shown/hidden m_videoWindow into account: - qApp->processEvents(); - resize(sizeHint()); - } else - resize(minimumSize()); - } - } - - switch (newstate) { - case Phonon::ErrorState: - QMessageBox::warning(this, "Phonon Mediaplayer", m_MediaObject.errorString(), QMessageBox::Close); - if (m_MediaObject.errorType() == Phonon::FatalError) { - playButton->setEnabled(false); - rewindButton->setEnabled(false); - } else { - m_MediaObject.pause(); - } - break; - case Phonon::PausedState: - case Phonon::StoppedState: - playButton->setIcon(playIcon); - if (m_MediaObject.currentSource().type() != Phonon::MediaSource::Invalid){ - playButton->setEnabled(true); - rewindButton->setEnabled(true); - } else { - playButton->setEnabled(false); - rewindButton->setEnabled(false); - } - break; - case Phonon::PlayingState: - playButton->setEnabled(true); - playButton->setIcon(pauseIcon); - if (m_MediaObject.hasVideo()) - m_videoWindow.show(); - // Fall through - case Phonon::BufferingState: - rewindButton->setEnabled(true); - break; - case Phonon::LoadingState: - rewindButton->setEnabled(false); - break; - } - -} - -void MediaPlayer::initSettingsDialog() -{ - settingsDialog = new QDialog(this); - ui = new Ui_settings(); - ui->setupUi(settingsDialog); - - connect(ui->brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrightness(int))); - connect(ui->hueSlider, SIGNAL(valueChanged(int)), this, SLOT(setHue(int))); - connect(ui->saturationSlider, SIGNAL(valueChanged(int)), this, SLOT(setSaturation(int))); - connect(ui->contrastSlider , SIGNAL(valueChanged(int)), this, SLOT(setContrast(int))); - connect(ui->aspectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setAspect(int))); - connect(ui->scalemodeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setScale(int))); - - ui->brightnessSlider->setValue(int(m_videoWidget->brightness() * SLIDER_RANGE)); - ui->hueSlider->setValue(int(m_videoWidget->hue() * SLIDER_RANGE)); - ui->saturationSlider->setValue(int(m_videoWidget->saturation() * SLIDER_RANGE)); - ui->contrastSlider->setValue(int(m_videoWidget->contrast() * SLIDER_RANGE)); - ui->aspectCombo->setCurrentIndex(m_videoWidget->aspectRatio()); - ui->scalemodeCombo->setCurrentIndex(m_videoWidget->scaleMode()); - connect(ui->effectButton, SIGNAL(clicked()), this, SLOT(configureEffect())); - -#ifdef Q_WS_X11 - //Cross fading is not currently implemented in the GStreamer backend - ui->crossFadeSlider->setVisible(false); - ui->crossFadeLabel->setVisible(false); - ui->crossFadeLabel1->setVisible(false); - ui->crossFadeLabel2->setVisible(false); - ui->crossFadeLabel3->setVisible(false); -#endif - ui->crossFadeSlider->setValue((int)(2 * m_MediaObject.transitionTime() / 1000.0f)); - - // Insert audio devices: - QList devices = Phonon::BackendCapabilities::availableAudioOutputDevices(); - for (int i=0; ideviceCombo->addItem(itemText); - if (devices[i] == m_AudioOutput.outputDevice()) - ui->deviceCombo->setCurrentIndex(i); - } - - // Insert audio effects: - ui->audioEffectsCombo->addItem(tr("")); - QList currEffects = m_audioOutputPath.effects(); - Phonon::Effect *currEffect = currEffects.size() ? currEffects[0] : 0; - QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); - for (int i=0; iaudioEffectsCombo->addItem(availableEffects[i].name()); - if (currEffect && availableEffects[i] == currEffect->description()) - ui->audioEffectsCombo->setCurrentIndex(i+1); - } - connect(ui->audioEffectsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(effectChanged())); - -} - -void MediaPlayer::effectChanged() -{ - int currentIndex = ui->audioEffectsCombo->currentIndex(); - if (currentIndex) { - QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); - Phonon::EffectDescription chosenEffect = availableEffects[currentIndex - 1]; - - QList currEffects = m_audioOutputPath.effects(); - Phonon::Effect *currentEffect = currEffects.size() ? currEffects[0] : 0; - - // Deleting the running effect will stop playback, it is deleted when removed from path - if (nextEffect && !(currentEffect && (currentEffect->description().name() == nextEffect->description().name()))) - delete nextEffect; - - nextEffect = new Phonon::Effect(chosenEffect); - } - ui->effectButton->setEnabled(currentIndex); -} - -void MediaPlayer::showSettingsDialog() -{ - if (!settingsDialog) - initSettingsDialog(); - - float oldBrightness = m_videoWidget->brightness(); - float oldHue = m_videoWidget->hue(); - float oldSaturation = m_videoWidget->saturation(); - float oldContrast = m_videoWidget->contrast(); - Phonon::VideoWidget::AspectRatio oldAspect = m_videoWidget->aspectRatio(); - Phonon::VideoWidget::ScaleMode oldScale = m_videoWidget->scaleMode(); - int currentEffect = ui->audioEffectsCombo->currentIndex(); - settingsDialog->exec(); - - if (settingsDialog->result() == QDialog::Accepted){ - m_MediaObject.setTransitionTime((int)(1000 * float(ui->crossFadeSlider->value()) / 2.0f)); - QList devices = Phonon::BackendCapabilities::availableAudioOutputDevices(); - m_AudioOutput.setOutputDevice(devices[ui->deviceCombo->currentIndex()]); - QList currEffects = m_audioOutputPath.effects(); - QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); - - if (ui->audioEffectsCombo->currentIndex() > 0){ - Phonon::Effect *currentEffect = currEffects.size() ? currEffects[0] : 0; - if (!currentEffect || currentEffect->description() != nextEffect->description()){ - foreach(Phonon::Effect *effect, currEffects) { - m_audioOutputPath.removeEffect(effect); - delete effect; - } - m_audioOutputPath.insertEffect(nextEffect); - } - } else { - foreach(Phonon::Effect *effect, currEffects) { - m_audioOutputPath.removeEffect(effect); - delete effect; - nextEffect = 0; - } - } - } else { - // Restore previous settings - m_videoWidget->setBrightness(oldBrightness); - m_videoWidget->setSaturation(oldSaturation); - m_videoWidget->setHue(oldHue); - m_videoWidget->setContrast(oldContrast); - m_videoWidget->setAspectRatio(oldAspect); - m_videoWidget->setScaleMode(oldScale); - ui->audioEffectsCombo->setCurrentIndex(currentEffect); - } -} - -void MediaPlayer::initVideoWindow() -{ - QVBoxLayout *videoLayout = new QVBoxLayout(); - videoLayout->addWidget(m_videoWidget); - videoLayout->setContentsMargins(0, 0, 0, 0); - m_videoWindow.setLayout(videoLayout); - m_videoWindow.setMinimumSize(100, 100); -} - - -void MediaPlayer::configureEffect() -{ - if (!nextEffect) - return; - - - QList currEffects = m_audioOutputPath.effects(); - const QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); - if (ui->audioEffectsCombo->currentIndex() > 0) { - Phonon::EffectDescription chosenEffect = availableEffects[ui->audioEffectsCombo->currentIndex() - 1]; - - QDialog effectDialog; - effectDialog.setWindowTitle(tr("Configure effect")); - QVBoxLayout *topLayout = new QVBoxLayout(&effectDialog); - - QLabel *description = new QLabel("Description:
" + chosenEffect.description(), &effectDialog); - description->setWordWrap(true); - topLayout->addWidget(description); - - QScrollArea *scrollArea = new QScrollArea(&effectDialog); - topLayout->addWidget(scrollArea); - - QVariantList savedParamValues; - foreach(Phonon::EffectParameter param, nextEffect->parameters()) { - savedParamValues << nextEffect->parameterValue(param); - } - - QWidget *scrollWidget = new Phonon::EffectWidget(nextEffect); - scrollWidget->setMinimumWidth(320); - scrollWidget->setContentsMargins(10, 10, 10,10); - scrollArea->setWidget(scrollWidget); - - QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &effectDialog); - connect(bbox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), &effectDialog, SLOT(accept())); - connect(bbox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), &effectDialog, SLOT(reject())); - topLayout->addWidget(bbox); - - effectDialog.exec(); - - if (effectDialog.result() != QDialog::Accepted) { - //we need to restore the paramaters values - int currentIndex = 0; - foreach(Phonon::EffectParameter param, nextEffect->parameters()) { - nextEffect->setParameterValue(param, savedParamValues.at(currentIndex++)); - } - - } - } -} - -void MediaPlayer::handleDrop(QDropEvent *e) -{ - QList urls = e->mimeData()->urls(); - if (e->proposedAction() == Qt::MoveAction){ - // Just add to the queue: - for (int i=0; i 0) { - QString fileName = urls[0].toLocalFile(); - QDir dir(fileName); - if (dir.exists()) { - dir.setFilter(QDir::Files); - QStringList entries = dir.entryList(); - if (entries.size() > 0) { - setFile(fileName + QDir::separator() + entries[0]); - for (int i=1; i< entries.size(); ++i) - m_MediaObject.enqueue(fileName + QDir::separator() + entries[i]); - } - } else { - setFile(fileName); - for (int i=1; isetEnabled(m_MediaObject.queue().size() > 0); - m_MediaObject.play(); -} - -void MediaPlayer::dropEvent(QDropEvent *e) -{ - if (e->mimeData()->hasUrls() && e->proposedAction() != Qt::LinkAction) { - e->acceptProposedAction(); - handleDrop(e); - } else { - e->ignore(); - } -} - -void MediaPlayer::dragEnterEvent(QDragEnterEvent *e) -{ - dragMoveEvent(e); -} - -void MediaPlayer::dragMoveEvent(QDragMoveEvent *e) -{ - if (e->mimeData()->hasUrls()) { - if (e->proposedAction() == Qt::CopyAction || e->proposedAction() == Qt::MoveAction){ - e->acceptProposedAction(); - } - } -} - -void MediaPlayer::playPause() -{ - if (m_MediaObject.state() == Phonon::PlayingState) - m_MediaObject.pause(); - else { - if (m_MediaObject.currentTime() == m_MediaObject.totalTime()) - m_MediaObject.seek(0); - m_MediaObject.play(); - } -} - -void MediaPlayer::setFile(const QString &fileName) -{ - setWindowTitle(fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1)); - m_MediaObject.setCurrentSource(Phonon::MediaSource(fileName)); - m_MediaObject.play(); -} - -void MediaPlayer::openFile() -{ - QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), - QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); - m_MediaObject.clearQueue(); - if (fileNames.size() > 0) { - QString fileName = fileNames[0]; - setFile(fileName); - for (int i=1; isetEnabled(m_MediaObject.queue().size() > 0); -} - -void MediaPlayer::bufferStatus(int percent) -{ - if (percent == 0 || percent == 100) - progressLabel->setText(QString()); - else { - QString str = QString::fromLatin1("(%1%)").arg(percent); - progressLabel->setText(str); - } -} - -void MediaPlayer::setSaturation(int val) -{ - m_videoWidget->setSaturation(val / qreal(SLIDER_RANGE)); -} - -void MediaPlayer::setHue(int val) -{ - m_videoWidget->setHue(val / qreal(SLIDER_RANGE)); -} - -void MediaPlayer::setAspect(int val) -{ - m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio(val)); -} - -void MediaPlayer::setScale(int val) -{ - m_videoWidget->setScaleMode(Phonon::VideoWidget::ScaleMode(val)); -} - -void MediaPlayer::setBrightness(int val) -{ - m_videoWidget->setBrightness(val / qreal(SLIDER_RANGE)); -} - -void MediaPlayer::setContrast(int val) -{ - m_videoWidget->setContrast(val / qreal(SLIDER_RANGE)); -} - -void MediaPlayer::updateInfo() -{ - int maxLength = 30; - QString font = ""; - QString fontmono = ""; - - QMap metaData = m_MediaObject.metaData(); - QString trackArtist = metaData.value("ARTIST"); - if (trackArtist.length() > maxLength) - trackArtist = trackArtist.left(maxLength) + "..."; - - QString trackTitle = metaData.value("TITLE"); - int trackBitrate = metaData.value("BITRATE").toInt(); - - QString fileName; - if (m_MediaObject.currentSource().type() == Phonon::MediaSource::Url) { - fileName = m_MediaObject.currentSource().url().toString(); - } else { - fileName = m_MediaObject.currentSource().fileName(); - fileName = fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1); - if (fileName.length() > maxLength) - fileName = fileName.left(maxLength) + "..."; - } - - QString title; - if (!trackTitle.isEmpty()) { - if (trackTitle.length() > maxLength) - trackTitle = trackTitle.left(maxLength) + "..."; - title = "Title: " + font + trackTitle + "
"; - } else if (!fileName.isEmpty()) { - if (fileName.length() > maxLength) - fileName = fileName.left(maxLength) + "..."; - title = font + fileName + "
"; - if (m_MediaObject.currentSource().type() == Phonon::MediaSource::Url) { - title.prepend("Url: "); - } else { - title.prepend("File: "); - } - } - - QString artist; - if (!trackArtist.isEmpty()) - artist = "Artist: " + font + trackArtist + ""; - - QString bitrate; - if (trackBitrate != 0) - bitrate = "
Bitrate: " + font + QString::number(trackBitrate/1000) + "kbit"; - - info->setText(title + artist + bitrate); -} - -void MediaPlayer::updateTime() -{ - long len = m_MediaObject.totalTime(); - long pos = m_MediaObject.currentTime(); - QString timeString; - if (pos || len) - { - int sec = pos/1000; - int min = sec/60; - int hour = min/60; - int msec = pos; - - QTime playTime(hour%60, min%60, sec%60, msec%1000); - sec = len / 1000; - min = sec / 60; - hour = min / 60; - msec = len; - - QTime stopTime(hour%60, min%60, sec%60, msec%1000); - QString timeFormat = "m:ss"; - if (hour > 0) - timeFormat = "h:mm:ss"; - timeString = playTime.toString(timeFormat); - if (len) - timeString += " / " + stopTime.toString(timeFormat); - } - timeLabel->setText(timeString); -} - -void MediaPlayer::rewind() -{ - m_MediaObject.seek(0); -} - -void MediaPlayer::forward() -{ - QList queue = m_MediaObject.queue(); - if (queue.size() > 0) { - m_MediaObject.setCurrentSource(queue[0]); - forwardButton->setEnabled(queue.size() > 1); - m_MediaObject.play(); - } -} - -void MediaPlayer::openUrl() -{ - QSettings settings; - settings.beginGroup(QLatin1String("BrowserMainWindow")); - QString sourceURL = settings.value("location").toString(); - bool ok = false; - sourceURL = QInputDialog::getText(this, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL, &ok); - if (ok && !sourceURL.isEmpty()) { - setWindowTitle(sourceURL.right(sourceURL.length() - sourceURL.lastIndexOf('/') - 1)); - m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(sourceURL.toUtf8()))); - m_MediaObject.play(); - settings.setValue("location", sourceURL); - } -} - -void MediaPlayer::finished() -{ -} - -void MediaPlayer::showContextMenu(const QPoint &p) -{ - fileMenu->popup(m_videoWidget->isFullScreen() ? p : mapToGlobal(p)); -} - -void MediaPlayer::scaleChanged(QAction *act) -{ - if (act->text() == tr("Scale and crop")) - m_videoWidget->setScaleMode(Phonon::VideoWidget::ScaleAndCrop); - else - m_videoWidget->setScaleMode(Phonon::VideoWidget::FitInView); -} - -void MediaPlayer::aspectChanged(QAction *act) -{ - if (act->text() == tr("16/9")) - m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio16_9); - else if (act->text() == tr("Scale")) - m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioWidget); - else if (act->text() == tr("4/3")) - m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio4_3); - else - m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioAuto); -} - diff --git a/demos/mediaplayer/mediaplayer.h b/demos/mediaplayer/mediaplayer.h deleted file mode 100644 index 40ffa40..0000000 --- a/demos/mediaplayer/mediaplayer.h +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -***************************************************************************/ - -#ifndef MEDIALAYER_H -#define MEDIAPLAYER_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QPushButton; -class QLabel; -class QSlider; -class QTextEdit; -class QMenu; -class Ui_settings; -QT_END_NAMESPACE - -class MediaPlayer : - public QWidget -{ - Q_OBJECT -public: - MediaPlayer(const QString &, - const bool hasSmallScreen); - - void dragEnterEvent(QDragEnterEvent *e); - void dragMoveEvent(QDragMoveEvent *e); - void dropEvent(QDropEvent *e); - void handleDrop(QDropEvent *e); - void setFile(const QString &text); - void initVideoWindow(); - void initSettingsDialog(); - -public slots: - void openFile(); - void rewind(); - void forward(); - void updateInfo(); - void updateTime(); - void finished(); - void playPause(); - void scaleChanged(QAction *); - void aspectChanged(QAction *); - -private slots: - void setAspect(int); - void setScale(int); - void setSaturation(int); - void setContrast(int); - void setHue(int); - void setBrightness(int); - void stateChanged(Phonon::State newstate, Phonon::State oldstate); - void effectChanged(); - void showSettingsDialog(); - void showContextMenu(const QPoint &); - void bufferStatus(int percent); - void openUrl(); - void configureEffect(); - -private: - QIcon playIcon; - QIcon pauseIcon; - QMenu *fileMenu; - QPushButton *playButton; - QPushButton *rewindButton; - QPushButton *forwardButton; - Phonon::SeekSlider *slider; - QLabel *timeLabel; - QLabel *progressLabel; - Phonon::VolumeSlider *volume; - QSlider *m_hueSlider; - QSlider *m_satSlider; - QSlider *m_contSlider; - QLabel *info; - Phonon::Effect *nextEffect; - QDialog *settingsDialog; - Ui_settings *ui; - - QWidget m_videoWindow; - Phonon::MediaObject m_MediaObject; - Phonon::AudioOutput m_AudioOutput; - Phonon::VideoWidget *m_videoWidget; - Phonon::Path m_audioOutputPath; - const bool m_hasSmallScreen; -}; - -#endif //MEDIAPLAYER_H diff --git a/demos/mediaplayer/mediaplayer.pro b/demos/mediaplayer/mediaplayer.pro deleted file mode 100644 index a420cc3..0000000 --- a/demos/mediaplayer/mediaplayer.pro +++ /dev/null @@ -1,36 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Thu Aug 23 18:02:14 2007 -###################################################################### - -TEMPLATE = app -TARGET = qmediaplayer -DEPENDPATH += . build src ui - -QT += phonon - -FORMS += settings.ui -RESOURCES += mediaplayer.qrc - -!win32:CONFIG += CONSOLE - -SOURCES += main.cpp mediaplayer.cpp -HEADERS += mediaplayer.h - -target.path = $$[QT_INSTALL_DEMOS]/qmediaplayer -sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.html *.doc images -sources.path = $$[QT_INSTALL_DEMOS]/mediaplayer -INSTALLS += target sources - -wince*{ -DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout -} - -symbian { - TARGET.UID3 = 0xA000C613 - - addFiles.sources = ../embedded/desktopservices/data/sax.mp3 - addFiles.path = /data/sounds/ - DEPLOYMENT += addFiles - - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) -} diff --git a/demos/mediaplayer/mediaplayer.qrc b/demos/mediaplayer/mediaplayer.qrc deleted file mode 100644 index bcdf404..0000000 --- a/demos/mediaplayer/mediaplayer.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/screen.png - - diff --git a/demos/mediaplayer/settings.ui b/demos/mediaplayer/settings.ui deleted file mode 100644 index d2cedd4..0000000 --- a/demos/mediaplayer/settings.ui +++ /dev/null @@ -1,464 +0,0 @@ - - settings - - - - 0 - 0 - 360 - 362 - - - - Settings - - - - - - Video options: - - - true - - - - - - Contrast: - - - - - - - -8 - - - 8 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 4 - - - - - - - Brightness: - - - - - - - -8 - - - 8 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 4 - - - - - - - Saturation: - - - - - - - -8 - - - 8 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 4 - - - - - - - Hue: - - - - - - - -8 - - - 8 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 4 - - - - - - - Aspect ratio: - - - - - - - - 180 - 0 - - - - - Auto - - - - - Stretch - - - - - 4/3 - - - - - 16/9 - - - - - - - - Scale Mode: - - - - - - - - 180 - 0 - - - - - Fit in view - - - - - Scale and crop - - - - - - - - - - - Audio options: - - - true - - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - Audio device: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - 0 - - - - - - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - Audio effect: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - 0 - - - - - - - - false - - - Setup - - - - - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - Cross fade: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - - 0 - 0 - - - - -20 - - - 20 - - - 1 - - - 2 - - - 0 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - - - - - - - - 9 - - - - -10 Sec - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 9 - - - - 0 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 9 - - - - 10 Sec - - - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - settings - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - settings - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/demos/qmediaplayer/images/screen.png b/demos/qmediaplayer/images/screen.png new file mode 100644 index 0000000..a15df92 Binary files /dev/null and b/demos/qmediaplayer/images/screen.png differ diff --git a/demos/qmediaplayer/main.cpp b/demos/qmediaplayer/main.cpp new file mode 100644 index 0000000..66aa445 --- /dev/null +++ b/demos/qmediaplayer/main.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +***************************************************************************/ + +#include +#include "mediaplayer.h" + +int main (int argc, char *argv[]) +{ + Q_INIT_RESOURCE(mediaplayer); + QApplication app(argc, argv); + app.setApplicationName("Media Player"); + app.setOrganizationName("Qt"); + app.setQuitOnLastWindowClosed(true); + + bool hasSmallScreen = +#ifdef Q_OS_SYMBIAN + /* On Symbian, we always want fullscreen. One reason is that it's not + * possible to launch any demos from the fluidlauncher due to a + * limitation in the emulator. */ + true +#else + false +#endif + ; + + QString fileString; + const QStringList args(app.arguments()); + /* We have a minor problem here, we accept two arguments, both are + * optional: + * - A file name + * - the option "-small-screen", so let's try to cope with that. + */ + for (int i = 0; i < args.count(); ++i) { + const QString &at = args.at(i); + + if (at == QLatin1String("-small-screen")) + hasSmallScreen = true; + else if (i > 0) // We don't want the app name. + fileString = at; + } + + MediaPlayer player(fileString, hasSmallScreen); + + if (hasSmallScreen) + player.showMaximized(); + else + player.show(); + + return app.exec(); +} + diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp new file mode 100644 index 0000000..baac236 --- /dev/null +++ b/demos/qmediaplayer/mediaplayer.cpp @@ -0,0 +1,845 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +***************************************************************************/ + +#include + +#define SLIDER_RANGE 8 + +#include "mediaplayer.h" +#include "ui_settings.h" + + +class MediaVideoWidget : public Phonon::VideoWidget +{ +public: + MediaVideoWidget(MediaPlayer *player, QWidget *parent = 0) : + Phonon::VideoWidget(parent), m_player(player), m_action(this) + { + m_action.setCheckable(true); + m_action.setChecked(false); + m_action.setShortcut(QKeySequence( Qt::AltModifier + Qt::Key_Return)); + m_action.setShortcutContext(Qt::WindowShortcut); + connect(&m_action, SIGNAL(toggled(bool)), SLOT(setFullScreen(bool))); + addAction(&m_action); + setAcceptDrops(true); + } + +protected: + void mouseDoubleClickEvent(QMouseEvent *e) + { + Phonon::VideoWidget::mouseDoubleClickEvent(e); + setFullScreen(!isFullScreen()); + } + + void keyPressEvent(QKeyEvent *e) + { + if (e->key() == Qt::Key_Space && !e->modifiers()) { + m_player->playPause(); + e->accept(); + return; + } else if (e->key() == Qt::Key_Escape && !e->modifiers()) { + setFullScreen(false); + e->accept(); + return; + } + Phonon::VideoWidget::keyPressEvent(e); + } + + bool event(QEvent *e) + { + switch(e->type()) + { + case QEvent::Close: + //we just ignore the cose events on the video widget + //this prevents ALT+F4 from having an effect in fullscreen mode + e->ignore(); + return true; + case QEvent::MouseMove: +#ifndef QT_NO_CURSOR + unsetCursor(); +#endif + //fall through + case QEvent::WindowStateChange: + { + //we just update the state of the checkbox, in case it wasn't already + m_action.setChecked(windowState() & Qt::WindowFullScreen); + const Qt::WindowFlags flags = m_player->windowFlags(); + if (windowState() & Qt::WindowFullScreen) { + m_timer.start(1000, this); + } else { + m_timer.stop(); +#ifndef QT_NO_CURSOR + unsetCursor(); +#endif + } + } + break; + default: + break; + } + + return Phonon::VideoWidget::event(e); + } + + void timerEvent(QTimerEvent *e) + { + if (e->timerId() == m_timer.timerId()) { + //let's store the cursor shape +#ifndef QT_NO_CURSOR + setCursor(Qt::BlankCursor); +#endif + } + Phonon::VideoWidget::timerEvent(e); + } + + void dropEvent(QDropEvent *e) + { + m_player->handleDrop(e); + } + + void dragEnterEvent(QDragEnterEvent *e) { + if (e->mimeData()->hasUrls()) + e->acceptProposedAction(); + } + +private: + MediaPlayer *m_player; + QBasicTimer m_timer; + QAction m_action; +}; + + +MediaPlayer::MediaPlayer(const QString &filePath, + const bool hasSmallScreen) : + playButton(0), nextEffect(0), settingsDialog(0), ui(0), + m_AudioOutput(Phonon::VideoCategory), + m_videoWidget(new MediaVideoWidget(this)), + m_hasSmallScreen(hasSmallScreen) +{ + setWindowTitle(tr("Media Player")); + setContextMenuPolicy(Qt::CustomContextMenu); + m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); + + QSize buttonSize(34, 28); + + QPushButton *openButton = new QPushButton(this); + + openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); + QPalette bpal; + QColor arrowcolor = bpal.buttonText().color(); + if (arrowcolor == Qt::black) + arrowcolor = QColor(80, 80, 80); + bpal.setBrush(QPalette::ButtonText, arrowcolor); + openButton->setPalette(bpal); + + rewindButton = new QPushButton(this); + rewindButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); + + forwardButton = new QPushButton(this); + forwardButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); + forwardButton->setEnabled(false); + + playButton = new QPushButton(this); + playIcon = style()->standardIcon(QStyle::SP_MediaPlay); + pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); + playButton->setIcon(playIcon); + + slider = new Phonon::SeekSlider(this); + slider->setMediaObject(&m_MediaObject); + volume = new Phonon::VolumeSlider(&m_AudioOutput); + + QVBoxLayout *vLayout = new QVBoxLayout(this); + vLayout->setContentsMargins(8, 8, 8, 8); + + QHBoxLayout *layout = new QHBoxLayout(); + + info = new QLabel(this); + info->setMinimumHeight(70); + info->setAcceptDrops(false); + info->setMargin(2); + info->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); + info->setLineWidth(2); + info->setAutoFillBackground(true); + + QPalette palette; + palette.setBrush(QPalette::WindowText, Qt::white); +#ifndef Q_WS_MAC + openButton->setMinimumSize(54, buttonSize.height()); + rewindButton->setMinimumSize(buttonSize); + forwardButton->setMinimumSize(buttonSize); + playButton->setMinimumSize(buttonSize); +#endif + info->setStyleSheet("border-image:url(:/images/screen.png) ; border-width:3px"); + info->setPalette(palette); + info->setText(tr("
No media
")); + + volume->setFixedWidth(120); + + layout->addWidget(openButton); + layout->addWidget(rewindButton); + layout->addWidget(playButton); + layout->addWidget(forwardButton); + + layout->addStretch(); + layout->addWidget(volume); + + vLayout->addWidget(info); + initVideoWindow(); + vLayout->addWidget(&m_videoWindow); + QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); + m_videoWindow.hide(); + buttonPanelLayout->addLayout(layout); + + timeLabel = new QLabel(this); + progressLabel = new QLabel(this); + QWidget *sliderPanel = new QWidget(this); + QHBoxLayout *sliderLayout = new QHBoxLayout(); + sliderLayout->addWidget(slider); + sliderLayout->addWidget(timeLabel); + sliderLayout->addWidget(progressLabel); + sliderLayout->setContentsMargins(0, 0, 0, 0); + sliderPanel->setLayout(sliderLayout); + + buttonPanelLayout->addWidget(sliderPanel); + buttonPanelLayout->setContentsMargins(0, 0, 0, 0); +#ifdef Q_OS_MAC + layout->setSpacing(4); + buttonPanelLayout->setSpacing(0); + info->setMinimumHeight(100); + info->setFont(QFont("verdana", 15)); + // QStyle *flatButtonStyle = new QWindowsStyle; + openButton->setFocusPolicy(Qt::NoFocus); + // openButton->setStyle(flatButtonStyle); + // playButton->setStyle(flatButtonStyle); + // rewindButton->setStyle(flatButtonStyle); + // forwardButton->setStyle(flatButtonStyle); + #endif + QWidget *buttonPanelWidget = new QWidget(this); + buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + buttonPanelWidget->setLayout(buttonPanelLayout); + vLayout->addWidget(buttonPanelWidget); + + QHBoxLayout *labelLayout = new QHBoxLayout(); + + vLayout->addLayout(labelLayout); + setLayout(vLayout); + + // Create menu bar: + fileMenu = new QMenu(this); + QAction *openFileAction = fileMenu->addAction(tr("Open &File...")); + QAction *openUrlAction = fileMenu->addAction(tr("Open &Location...")); + + fileMenu->addSeparator(); + QMenu *aspectMenu = fileMenu->addMenu(tr("&Aspect ratio")); + QActionGroup *aspectGroup = new QActionGroup(aspectMenu); + connect(aspectGroup, SIGNAL(triggered(QAction *)), this, SLOT(aspectChanged(QAction *))); + aspectGroup->setExclusive(true); + QAction *aspectActionAuto = aspectMenu->addAction(tr("Auto")); + aspectActionAuto->setCheckable(true); + aspectActionAuto->setChecked(true); + aspectGroup->addAction(aspectActionAuto); + QAction *aspectActionScale = aspectMenu->addAction(tr("Scale")); + aspectActionScale->setCheckable(true); + aspectGroup->addAction(aspectActionScale); + QAction *aspectAction16_9 = aspectMenu->addAction(tr("16/9")); + aspectAction16_9->setCheckable(true); + aspectGroup->addAction(aspectAction16_9); + QAction *aspectAction4_3 = aspectMenu->addAction(tr("4/3")); + aspectAction4_3->setCheckable(true); + aspectGroup->addAction(aspectAction4_3); + + QMenu *scaleMenu = fileMenu->addMenu(tr("&Scale mode")); + QActionGroup *scaleGroup = new QActionGroup(scaleMenu); + connect(scaleGroup, SIGNAL(triggered(QAction *)), this, SLOT(scaleChanged(QAction *))); + scaleGroup->setExclusive(true); + QAction *scaleActionFit = scaleMenu->addAction(tr("Fit in view")); + scaleActionFit->setCheckable(true); + scaleActionFit->setChecked(true); + scaleGroup->addAction(scaleActionFit); + QAction *scaleActionCrop = scaleMenu->addAction(tr("Scale and crop")); + scaleActionCrop->setCheckable(true); + scaleGroup->addAction(scaleActionCrop); + + fileMenu->addSeparator(); + QAction *settingsAction = fileMenu->addAction(tr("&Settings...")); + + // Setup signal connections: + connect(rewindButton, SIGNAL(clicked()), this, SLOT(rewind())); + //connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); + openButton->setMenu(fileMenu); + + connect(playButton, SIGNAL(clicked()), this, SLOT(playPause())); + connect(forwardButton, SIGNAL(clicked()), this, SLOT(forward())); + //connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); + connect(settingsAction, SIGNAL(triggered(bool)), this, SLOT(showSettingsDialog())); + connect(openUrlAction, SIGNAL(triggered(bool)), this, SLOT(openUrl())); + connect(openFileAction, SIGNAL(triggered(bool)), this, SLOT(openFile())); + + connect(m_videoWidget, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); + connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); + connect(&m_MediaObject, SIGNAL(metaDataChanged()), this, SLOT(updateInfo())); + connect(&m_MediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateTime())); + connect(&m_MediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime())); + connect(&m_MediaObject, SIGNAL(finished()), this, SLOT(finished())); + connect(&m_MediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(stateChanged(Phonon::State, Phonon::State))); + connect(&m_MediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int))); + + rewindButton->setEnabled(false); + playButton->setEnabled(false); + setAcceptDrops(true); + + m_audioOutputPath = Phonon::createPath(&m_MediaObject, &m_AudioOutput); + Phonon::createPath(&m_MediaObject, m_videoWidget); + + if (!filePath.isEmpty()) + setFile(filePath); + resize(minimumSizeHint()); +} + +void MediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) +{ + Q_UNUSED(oldstate); + + if (oldstate == Phonon::LoadingState) { + m_videoWindow.setVisible(m_MediaObject.hasVideo()); + info->setVisible(!m_MediaObject.hasVideo()); + QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint()); + QRect newVideoRect = QApplication::desktop()->screenGeometry().intersected(videoHintRect); + if (!m_hasSmallScreen) { + if (m_MediaObject.hasVideo()) { + // Flush event que so that sizeHint takes the + // recently shown/hidden m_videoWindow into account: + qApp->processEvents(); + resize(sizeHint()); + } else + resize(minimumSize()); + } + } + + switch (newstate) { + case Phonon::ErrorState: + QMessageBox::warning(this, "Phonon Mediaplayer", m_MediaObject.errorString(), QMessageBox::Close); + if (m_MediaObject.errorType() == Phonon::FatalError) { + playButton->setEnabled(false); + rewindButton->setEnabled(false); + } else { + m_MediaObject.pause(); + } + break; + case Phonon::PausedState: + case Phonon::StoppedState: + playButton->setIcon(playIcon); + if (m_MediaObject.currentSource().type() != Phonon::MediaSource::Invalid){ + playButton->setEnabled(true); + rewindButton->setEnabled(true); + } else { + playButton->setEnabled(false); + rewindButton->setEnabled(false); + } + break; + case Phonon::PlayingState: + playButton->setEnabled(true); + playButton->setIcon(pauseIcon); + if (m_MediaObject.hasVideo()) + m_videoWindow.show(); + // Fall through + case Phonon::BufferingState: + rewindButton->setEnabled(true); + break; + case Phonon::LoadingState: + rewindButton->setEnabled(false); + break; + } + +} + +void MediaPlayer::initSettingsDialog() +{ + settingsDialog = new QDialog(this); + ui = new Ui_settings(); + ui->setupUi(settingsDialog); + + connect(ui->brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrightness(int))); + connect(ui->hueSlider, SIGNAL(valueChanged(int)), this, SLOT(setHue(int))); + connect(ui->saturationSlider, SIGNAL(valueChanged(int)), this, SLOT(setSaturation(int))); + connect(ui->contrastSlider , SIGNAL(valueChanged(int)), this, SLOT(setContrast(int))); + connect(ui->aspectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setAspect(int))); + connect(ui->scalemodeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setScale(int))); + + ui->brightnessSlider->setValue(int(m_videoWidget->brightness() * SLIDER_RANGE)); + ui->hueSlider->setValue(int(m_videoWidget->hue() * SLIDER_RANGE)); + ui->saturationSlider->setValue(int(m_videoWidget->saturation() * SLIDER_RANGE)); + ui->contrastSlider->setValue(int(m_videoWidget->contrast() * SLIDER_RANGE)); + ui->aspectCombo->setCurrentIndex(m_videoWidget->aspectRatio()); + ui->scalemodeCombo->setCurrentIndex(m_videoWidget->scaleMode()); + connect(ui->effectButton, SIGNAL(clicked()), this, SLOT(configureEffect())); + +#ifdef Q_WS_X11 + //Cross fading is not currently implemented in the GStreamer backend + ui->crossFadeSlider->setVisible(false); + ui->crossFadeLabel->setVisible(false); + ui->crossFadeLabel1->setVisible(false); + ui->crossFadeLabel2->setVisible(false); + ui->crossFadeLabel3->setVisible(false); +#endif + ui->crossFadeSlider->setValue((int)(2 * m_MediaObject.transitionTime() / 1000.0f)); + + // Insert audio devices: + QList devices = Phonon::BackendCapabilities::availableAudioOutputDevices(); + for (int i=0; ideviceCombo->addItem(itemText); + if (devices[i] == m_AudioOutput.outputDevice()) + ui->deviceCombo->setCurrentIndex(i); + } + + // Insert audio effects: + ui->audioEffectsCombo->addItem(tr("")); + QList currEffects = m_audioOutputPath.effects(); + Phonon::Effect *currEffect = currEffects.size() ? currEffects[0] : 0; + QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + for (int i=0; iaudioEffectsCombo->addItem(availableEffects[i].name()); + if (currEffect && availableEffects[i] == currEffect->description()) + ui->audioEffectsCombo->setCurrentIndex(i+1); + } + connect(ui->audioEffectsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(effectChanged())); + +} + +void MediaPlayer::effectChanged() +{ + int currentIndex = ui->audioEffectsCombo->currentIndex(); + if (currentIndex) { + QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + Phonon::EffectDescription chosenEffect = availableEffects[currentIndex - 1]; + + QList currEffects = m_audioOutputPath.effects(); + Phonon::Effect *currentEffect = currEffects.size() ? currEffects[0] : 0; + + // Deleting the running effect will stop playback, it is deleted when removed from path + if (nextEffect && !(currentEffect && (currentEffect->description().name() == nextEffect->description().name()))) + delete nextEffect; + + nextEffect = new Phonon::Effect(chosenEffect); + } + ui->effectButton->setEnabled(currentIndex); +} + +void MediaPlayer::showSettingsDialog() +{ + if (!settingsDialog) + initSettingsDialog(); + + float oldBrightness = m_videoWidget->brightness(); + float oldHue = m_videoWidget->hue(); + float oldSaturation = m_videoWidget->saturation(); + float oldContrast = m_videoWidget->contrast(); + Phonon::VideoWidget::AspectRatio oldAspect = m_videoWidget->aspectRatio(); + Phonon::VideoWidget::ScaleMode oldScale = m_videoWidget->scaleMode(); + int currentEffect = ui->audioEffectsCombo->currentIndex(); + settingsDialog->exec(); + + if (settingsDialog->result() == QDialog::Accepted){ + m_MediaObject.setTransitionTime((int)(1000 * float(ui->crossFadeSlider->value()) / 2.0f)); + QList devices = Phonon::BackendCapabilities::availableAudioOutputDevices(); + m_AudioOutput.setOutputDevice(devices[ui->deviceCombo->currentIndex()]); + QList currEffects = m_audioOutputPath.effects(); + QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + + if (ui->audioEffectsCombo->currentIndex() > 0){ + Phonon::Effect *currentEffect = currEffects.size() ? currEffects[0] : 0; + if (!currentEffect || currentEffect->description() != nextEffect->description()){ + foreach(Phonon::Effect *effect, currEffects) { + m_audioOutputPath.removeEffect(effect); + delete effect; + } + m_audioOutputPath.insertEffect(nextEffect); + } + } else { + foreach(Phonon::Effect *effect, currEffects) { + m_audioOutputPath.removeEffect(effect); + delete effect; + nextEffect = 0; + } + } + } else { + // Restore previous settings + m_videoWidget->setBrightness(oldBrightness); + m_videoWidget->setSaturation(oldSaturation); + m_videoWidget->setHue(oldHue); + m_videoWidget->setContrast(oldContrast); + m_videoWidget->setAspectRatio(oldAspect); + m_videoWidget->setScaleMode(oldScale); + ui->audioEffectsCombo->setCurrentIndex(currentEffect); + } +} + +void MediaPlayer::initVideoWindow() +{ + QVBoxLayout *videoLayout = new QVBoxLayout(); + videoLayout->addWidget(m_videoWidget); + videoLayout->setContentsMargins(0, 0, 0, 0); + m_videoWindow.setLayout(videoLayout); + m_videoWindow.setMinimumSize(100, 100); +} + + +void MediaPlayer::configureEffect() +{ + if (!nextEffect) + return; + + + QList currEffects = m_audioOutputPath.effects(); + const QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + if (ui->audioEffectsCombo->currentIndex() > 0) { + Phonon::EffectDescription chosenEffect = availableEffects[ui->audioEffectsCombo->currentIndex() - 1]; + + QDialog effectDialog; + effectDialog.setWindowTitle(tr("Configure effect")); + QVBoxLayout *topLayout = new QVBoxLayout(&effectDialog); + + QLabel *description = new QLabel("Description:
" + chosenEffect.description(), &effectDialog); + description->setWordWrap(true); + topLayout->addWidget(description); + + QScrollArea *scrollArea = new QScrollArea(&effectDialog); + topLayout->addWidget(scrollArea); + + QVariantList savedParamValues; + foreach(Phonon::EffectParameter param, nextEffect->parameters()) { + savedParamValues << nextEffect->parameterValue(param); + } + + QWidget *scrollWidget = new Phonon::EffectWidget(nextEffect); + scrollWidget->setMinimumWidth(320); + scrollWidget->setContentsMargins(10, 10, 10,10); + scrollArea->setWidget(scrollWidget); + + QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &effectDialog); + connect(bbox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), &effectDialog, SLOT(accept())); + connect(bbox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), &effectDialog, SLOT(reject())); + topLayout->addWidget(bbox); + + effectDialog.exec(); + + if (effectDialog.result() != QDialog::Accepted) { + //we need to restore the paramaters values + int currentIndex = 0; + foreach(Phonon::EffectParameter param, nextEffect->parameters()) { + nextEffect->setParameterValue(param, savedParamValues.at(currentIndex++)); + } + + } + } +} + +void MediaPlayer::handleDrop(QDropEvent *e) +{ + QList urls = e->mimeData()->urls(); + if (e->proposedAction() == Qt::MoveAction){ + // Just add to the queue: + for (int i=0; i 0) { + QString fileName = urls[0].toLocalFile(); + QDir dir(fileName); + if (dir.exists()) { + dir.setFilter(QDir::Files); + QStringList entries = dir.entryList(); + if (entries.size() > 0) { + setFile(fileName + QDir::separator() + entries[0]); + for (int i=1; i< entries.size(); ++i) + m_MediaObject.enqueue(fileName + QDir::separator() + entries[i]); + } + } else { + setFile(fileName); + for (int i=1; isetEnabled(m_MediaObject.queue().size() > 0); + m_MediaObject.play(); +} + +void MediaPlayer::dropEvent(QDropEvent *e) +{ + if (e->mimeData()->hasUrls() && e->proposedAction() != Qt::LinkAction) { + e->acceptProposedAction(); + handleDrop(e); + } else { + e->ignore(); + } +} + +void MediaPlayer::dragEnterEvent(QDragEnterEvent *e) +{ + dragMoveEvent(e); +} + +void MediaPlayer::dragMoveEvent(QDragMoveEvent *e) +{ + if (e->mimeData()->hasUrls()) { + if (e->proposedAction() == Qt::CopyAction || e->proposedAction() == Qt::MoveAction){ + e->acceptProposedAction(); + } + } +} + +void MediaPlayer::playPause() +{ + if (m_MediaObject.state() == Phonon::PlayingState) + m_MediaObject.pause(); + else { + if (m_MediaObject.currentTime() == m_MediaObject.totalTime()) + m_MediaObject.seek(0); + m_MediaObject.play(); + } +} + +void MediaPlayer::setFile(const QString &fileName) +{ + setWindowTitle(fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1)); + m_MediaObject.setCurrentSource(Phonon::MediaSource(fileName)); + m_MediaObject.play(); +} + +void MediaPlayer::openFile() +{ + QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), + QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); + m_MediaObject.clearQueue(); + if (fileNames.size() > 0) { + QString fileName = fileNames[0]; + setFile(fileName); + for (int i=1; isetEnabled(m_MediaObject.queue().size() > 0); +} + +void MediaPlayer::bufferStatus(int percent) +{ + if (percent == 0 || percent == 100) + progressLabel->setText(QString()); + else { + QString str = QString::fromLatin1("(%1%)").arg(percent); + progressLabel->setText(str); + } +} + +void MediaPlayer::setSaturation(int val) +{ + m_videoWidget->setSaturation(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::setHue(int val) +{ + m_videoWidget->setHue(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::setAspect(int val) +{ + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio(val)); +} + +void MediaPlayer::setScale(int val) +{ + m_videoWidget->setScaleMode(Phonon::VideoWidget::ScaleMode(val)); +} + +void MediaPlayer::setBrightness(int val) +{ + m_videoWidget->setBrightness(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::setContrast(int val) +{ + m_videoWidget->setContrast(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::updateInfo() +{ + int maxLength = 30; + QString font = ""; + QString fontmono = ""; + + QMap metaData = m_MediaObject.metaData(); + QString trackArtist = metaData.value("ARTIST"); + if (trackArtist.length() > maxLength) + trackArtist = trackArtist.left(maxLength) + "..."; + + QString trackTitle = metaData.value("TITLE"); + int trackBitrate = metaData.value("BITRATE").toInt(); + + QString fileName; + if (m_MediaObject.currentSource().type() == Phonon::MediaSource::Url) { + fileName = m_MediaObject.currentSource().url().toString(); + } else { + fileName = m_MediaObject.currentSource().fileName(); + fileName = fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1); + if (fileName.length() > maxLength) + fileName = fileName.left(maxLength) + "..."; + } + + QString title; + if (!trackTitle.isEmpty()) { + if (trackTitle.length() > maxLength) + trackTitle = trackTitle.left(maxLength) + "..."; + title = "Title: " + font + trackTitle + "
"; + } else if (!fileName.isEmpty()) { + if (fileName.length() > maxLength) + fileName = fileName.left(maxLength) + "..."; + title = font + fileName + "
"; + if (m_MediaObject.currentSource().type() == Phonon::MediaSource::Url) { + title.prepend("Url: "); + } else { + title.prepend("File: "); + } + } + + QString artist; + if (!trackArtist.isEmpty()) + artist = "Artist: " + font + trackArtist + ""; + + QString bitrate; + if (trackBitrate != 0) + bitrate = "
Bitrate: " + font + QString::number(trackBitrate/1000) + "kbit"; + + info->setText(title + artist + bitrate); +} + +void MediaPlayer::updateTime() +{ + long len = m_MediaObject.totalTime(); + long pos = m_MediaObject.currentTime(); + QString timeString; + if (pos || len) + { + int sec = pos/1000; + int min = sec/60; + int hour = min/60; + int msec = pos; + + QTime playTime(hour%60, min%60, sec%60, msec%1000); + sec = len / 1000; + min = sec / 60; + hour = min / 60; + msec = len; + + QTime stopTime(hour%60, min%60, sec%60, msec%1000); + QString timeFormat = "m:ss"; + if (hour > 0) + timeFormat = "h:mm:ss"; + timeString = playTime.toString(timeFormat); + if (len) + timeString += " / " + stopTime.toString(timeFormat); + } + timeLabel->setText(timeString); +} + +void MediaPlayer::rewind() +{ + m_MediaObject.seek(0); +} + +void MediaPlayer::forward() +{ + QList queue = m_MediaObject.queue(); + if (queue.size() > 0) { + m_MediaObject.setCurrentSource(queue[0]); + forwardButton->setEnabled(queue.size() > 1); + m_MediaObject.play(); + } +} + +void MediaPlayer::openUrl() +{ + QSettings settings; + settings.beginGroup(QLatin1String("BrowserMainWindow")); + QString sourceURL = settings.value("location").toString(); + bool ok = false; + sourceURL = QInputDialog::getText(this, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL, &ok); + if (ok && !sourceURL.isEmpty()) { + setWindowTitle(sourceURL.right(sourceURL.length() - sourceURL.lastIndexOf('/') - 1)); + m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(sourceURL.toUtf8()))); + m_MediaObject.play(); + settings.setValue("location", sourceURL); + } +} + +void MediaPlayer::finished() +{ +} + +void MediaPlayer::showContextMenu(const QPoint &p) +{ + fileMenu->popup(m_videoWidget->isFullScreen() ? p : mapToGlobal(p)); +} + +void MediaPlayer::scaleChanged(QAction *act) +{ + if (act->text() == tr("Scale and crop")) + m_videoWidget->setScaleMode(Phonon::VideoWidget::ScaleAndCrop); + else + m_videoWidget->setScaleMode(Phonon::VideoWidget::FitInView); +} + +void MediaPlayer::aspectChanged(QAction *act) +{ + if (act->text() == tr("16/9")) + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio16_9); + else if (act->text() == tr("Scale")) + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioWidget); + else if (act->text() == tr("4/3")) + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio4_3); + else + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioAuto); +} + diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h new file mode 100644 index 0000000..40ffa40 --- /dev/null +++ b/demos/qmediaplayer/mediaplayer.h @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +***************************************************************************/ + +#ifndef MEDIALAYER_H +#define MEDIAPLAYER_H + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QPushButton; +class QLabel; +class QSlider; +class QTextEdit; +class QMenu; +class Ui_settings; +QT_END_NAMESPACE + +class MediaPlayer : + public QWidget +{ + Q_OBJECT +public: + MediaPlayer(const QString &, + const bool hasSmallScreen); + + void dragEnterEvent(QDragEnterEvent *e); + void dragMoveEvent(QDragMoveEvent *e); + void dropEvent(QDropEvent *e); + void handleDrop(QDropEvent *e); + void setFile(const QString &text); + void initVideoWindow(); + void initSettingsDialog(); + +public slots: + void openFile(); + void rewind(); + void forward(); + void updateInfo(); + void updateTime(); + void finished(); + void playPause(); + void scaleChanged(QAction *); + void aspectChanged(QAction *); + +private slots: + void setAspect(int); + void setScale(int); + void setSaturation(int); + void setContrast(int); + void setHue(int); + void setBrightness(int); + void stateChanged(Phonon::State newstate, Phonon::State oldstate); + void effectChanged(); + void showSettingsDialog(); + void showContextMenu(const QPoint &); + void bufferStatus(int percent); + void openUrl(); + void configureEffect(); + +private: + QIcon playIcon; + QIcon pauseIcon; + QMenu *fileMenu; + QPushButton *playButton; + QPushButton *rewindButton; + QPushButton *forwardButton; + Phonon::SeekSlider *slider; + QLabel *timeLabel; + QLabel *progressLabel; + Phonon::VolumeSlider *volume; + QSlider *m_hueSlider; + QSlider *m_satSlider; + QSlider *m_contSlider; + QLabel *info; + Phonon::Effect *nextEffect; + QDialog *settingsDialog; + Ui_settings *ui; + + QWidget m_videoWindow; + Phonon::MediaObject m_MediaObject; + Phonon::AudioOutput m_AudioOutput; + Phonon::VideoWidget *m_videoWidget; + Phonon::Path m_audioOutputPath; + const bool m_hasSmallScreen; +}; + +#endif //MEDIAPLAYER_H diff --git a/demos/qmediaplayer/mediaplayer.qrc b/demos/qmediaplayer/mediaplayer.qrc new file mode 100644 index 0000000..bcdf404 --- /dev/null +++ b/demos/qmediaplayer/mediaplayer.qrc @@ -0,0 +1,5 @@ + + + images/screen.png + + diff --git a/demos/qmediaplayer/qmediaplayer.pro b/demos/qmediaplayer/qmediaplayer.pro new file mode 100644 index 0000000..2f15c28 --- /dev/null +++ b/demos/qmediaplayer/qmediaplayer.pro @@ -0,0 +1,35 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Thu Aug 23 18:02:14 2007 +###################################################################### + +TEMPLATE = app +DEPENDPATH += . build src ui + +QT += phonon + +FORMS += settings.ui +RESOURCES += mediaplayer.qrc + +!win32:CONFIG += CONSOLE + +SOURCES += main.cpp mediaplayer.cpp +HEADERS += mediaplayer.h + +target.path = $$[QT_INSTALL_DEMOS]/qmediaplayer +sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.html *.doc images +sources.path = $$[QT_INSTALL_DEMOS]/qmediaplayer +INSTALLS += target sources + +wince*{ +DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout +} + +symbian { + TARGET.UID3 = 0xA000C613 + + addFiles.sources = ../embedded/desktopservices/data/sax.mp3 + addFiles.path = /data/sounds/ + DEPLOYMENT += addFiles + + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) +} diff --git a/demos/qmediaplayer/settings.ui b/demos/qmediaplayer/settings.ui new file mode 100644 index 0000000..d2cedd4 --- /dev/null +++ b/demos/qmediaplayer/settings.ui @@ -0,0 +1,464 @@ + + settings + + + + 0 + 0 + 360 + 362 + + + + Settings + + + + + + Video options: + + + true + + + + + + Contrast: + + + + + + + -8 + + + 8 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 4 + + + + + + + Brightness: + + + + + + + -8 + + + 8 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 4 + + + + + + + Saturation: + + + + + + + -8 + + + 8 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 4 + + + + + + + Hue: + + + + + + + -8 + + + 8 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 4 + + + + + + + Aspect ratio: + + + + + + + + 180 + 0 + + + + + Auto + + + + + Stretch + + + + + 4/3 + + + + + 16/9 + + + + + + + + Scale Mode: + + + + + + + + 180 + 0 + + + + + Fit in view + + + + + Scale and crop + + + + + + + + + + + Audio options: + + + true + + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + Audio device: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + + + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + Audio effect: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + + + + + false + + + Setup + + + + + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + Cross fade: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + 0 + 0 + + + + -20 + + + 20 + + + 1 + + + 2 + + + 0 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + + + + + + + + 9 + + + + -10 Sec + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 9 + + + + 0 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 9 + + + + 10 Sec + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + settings + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + settings + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/demos/qtdemo/xml/examples.xml b/demos/qtdemo/xml/examples.xml index 3f0cd25..2c31484 100644 --- a/demos/qtdemo/xml/examples.xml +++ b/demos/qtdemo/xml/examples.xml @@ -121,7 +121,7 @@ - + @@ -152,7 +152,7 @@ - + diff --git a/doc/src/demos/mediaplayer.qdoc b/doc/src/demos/mediaplayer.qdoc index 9e6b3f9..17ae79b 100644 --- a/doc/src/demos/mediaplayer.qdoc +++ b/doc/src/demos/mediaplayer.qdoc @@ -40,7 +40,7 @@ ****************************************************************************/ /*! - \example demos/mediaplayer + \example demos/qmediaplayer \title Media Player The Media Player demonstration shows how \l{Phonon Module}{Phonon} diff --git a/doc/src/examples/ftp.qdoc b/doc/src/examples/ftp.qdoc index ec8584c..8fded88 100644 --- a/doc/src/examples/ftp.qdoc +++ b/doc/src/examples/ftp.qdoc @@ -78,13 +78,13 @@ \l{QFtp::Command}{commands} we request are finished, the progress of current commands, and information about files on the server. - \snippet examples/network/ftp/ftpwindow.h 0 + \snippet examples/network/qftp/ftpwindow.h 0 We will look at each slot when we examine the \c FtpWindow implementation in the next section. We also make use of a few private variables: - \snippet examples/network/ftp/ftpwindow.h 1 + \snippet examples/network/qftp/ftpwindow.h 1 The \c isDirectory hash keeps a history of all entries explored on the FTP server, and registers whether an entry represents a @@ -98,7 +98,7 @@ We move on to the slots, starting with \c connectOrDisconnect(). - \snippet examples/network/ftp/ftpwindow.cpp 0 + \snippet examples/network/qftp/ftpwindow.cpp 0 If \c ftp is already pointing to a QFtp object, we QFtp::Close its FTP connection and delete the object it points to. Note that we do @@ -106,7 +106,7 @@ to finish its abort operation. \dots - \snippet examples/network/ftp/ftpwindow.cpp 1 + \snippet examples/network/qftp/ftpwindow.cpp 1 If we get here, \c connectOrDisconnect() was called to establish a new FTP connection. We create a new QFtp for our new connection, @@ -118,7 +118,7 @@ is emitted repeatedly during an FTP file transfer, giving us progress reports. - \snippet examples/network/ftp/ftpwindow.cpp 2 + \snippet examples/network/qftp/ftpwindow.cpp 2 The \gui {Ftp Server} line edit contains the IP address or hostname of the server to which we want to connect. We first check @@ -134,39 +134,39 @@ We move on to the \c downloadFile() slot: - \snippet examples/network/ftp/ftpwindow.cpp 3 + \snippet examples/network/qftp/ftpwindow.cpp 3 \dots - \snippet examples/network/ftp/ftpwindow.cpp 4 + \snippet examples/network/qftp/ftpwindow.cpp 4 We first fetch the name of the file, which we find in the selected item of \c fileList. We then start the download by using QFtp::get(). QFtp will send progress signals during the download and a signal when the download is completed. - \snippet examples/network/ftp/ftpwindow.cpp 5 + \snippet examples/network/qftp/ftpwindow.cpp 5 QFtp supports canceling the download of files. - \snippet examples/network/ftp/ftpwindow.cpp 6 + \snippet examples/network/qftp/ftpwindow.cpp 6 The \c ftpCommandFinished() slot is called when QFtp has finished a QFtp::Command. If an error occurred during the command, QFtp will set \c error to one of the values in the QFtp::Error enum; otherwise, \c error is zero. - \snippet examples/network/ftp/ftpwindow.cpp 7 + \snippet examples/network/qftp/ftpwindow.cpp 7 After login, the QFtp::list() function will list the top-level directory on the server. addToList() is connected to QFtp::listInfo(), and will be invoked for each entry in that directory. - \snippet examples/network/ftp/ftpwindow.cpp 8 + \snippet examples/network/qftp/ftpwindow.cpp 8 When a \l{QFtp::}{Get} command is finished, a file has finished downloading (or an error occurred during the download). - \snippet examples/network/ftp/ftpwindow.cpp 9 + \snippet examples/network/qftp/ftpwindow.cpp 9 After a \l{QFtp::}{List} command is performed, we have to check if no entries were found (in which case our \c addToList() function @@ -174,7 +174,7 @@ Let's continue with the \c addToList() slot: - \snippet examples/network/ftp/ftpwindow.cpp 10 + \snippet examples/network/qftp/ftpwindow.cpp 10 When a new file has been resolved during a QFtp::List command, this slot is invoked with a QUrlInfo describing the file. We @@ -182,26 +182,26 @@ does not have a current item, we set the new item to be the current item. - \snippet examples/network/ftp/ftpwindow.cpp 11 + \snippet examples/network/qftp/ftpwindow.cpp 11 The \c processItem() slot is called when an item is double clicked in the \gui {File List}. If the item represents a directory, we want to load the contents of that directory with QFtp::list(). - \snippet examples/network/ftp/ftpwindow.cpp 12 + \snippet examples/network/qftp/ftpwindow.cpp 12 \c cdToParent() is invoked when the user requests to go to the parent directory of the one displayed in the file list. After changing the directory, we QFtp::List its contents. - \snippet examples/network/ftp/ftpwindow.cpp 13 + \snippet examples/network/qftp/ftpwindow.cpp 13 The \c updateDataTransferProgress() slot is called regularly by QFtp::dataTransferProgress() when a file download is in progress. We use a QProgressDialog to show the download progression to the user. - \snippet examples/network/ftp/ftpwindow.cpp 14 + \snippet examples/network/qftp/ftpwindow.cpp 14 The \c enableDownloadButton() is called whenever the current item in \c fileList changes. If the item represents a file, the \gui diff --git a/doc/src/examples/musicplayerexample.qdoc b/doc/src/examples/musicplayerexample.qdoc index 41c9f3a..7145583 100644 --- a/doc/src/examples/musicplayerexample.qdoc +++ b/doc/src/examples/musicplayerexample.qdoc @@ -40,7 +40,7 @@ ****************************************************************************/ /*! - \example phonon/musicplayer + \example phonon/qmusicplayer \title Music Player Example The Music Player Example shows how to use Phonon - the multimedia @@ -90,7 +90,7 @@ look at them when we walk through the \c MainWindow implementation. - \snippet examples/phonon/musicplayer/mainwindow.h 2 + \snippet examples/phonon/qmusicplayer/mainwindow.h 2 We use the \l{Phonon::}{SeekSlider} to move the current playback position in the media stream, and the \l{Phonon::}{VolumeSlider} @@ -99,7 +99,7 @@ metaInformationProvider, to get the meta information from the music files. More on this later. - \snippet examples/phonon/musicplayer/mainwindow.h 1 + \snippet examples/phonon/qmusicplayer/mainwindow.h 1 The \l{Phonon::}{MediaObject} informs us of the state of the playback and properties of the media it is playing back through a series of @@ -116,7 +116,7 @@ We start with the constructor: - \snippet examples/phonon/musicplayer/mainwindow.cpp 0 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 0 We start by instantiating our media and audio output objects. As mentioned, the media object knows how to playback @@ -130,20 +130,20 @@ paths. Objects are connected using the \c createPath() function, which is part of the Phonon namespace. - \snippet examples/phonon/musicplayer/mainwindow.cpp 1 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 1 We also connect signals of the media object to slots in our \c MainWindow. We will examine them shortly. - \snippet examples/phonon/musicplayer/mainwindow.cpp 2 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 2 Finally, we call private helper functions to set up the GUI. The \c setupUi() function contains code for setting up the seek , and volume slider. We move on to \c setupUi(): - \snippet examples/phonon/musicplayer/mainwindow.cpp 3 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 3 \dots - \snippet examples/phonon/musicplayer/mainwindow.cpp 4 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 4 After creating the widgets, they must be supplied with the \l{Phonon::}{MediaObject} and \l{Phonon::}{AudioOutput} objects @@ -152,12 +152,12 @@ In the \c setupActions(), we connect the actions for the play, pause, and stop tool buttons, to slots of the media object. - \snippet examples/phonon/musicplayer/mainwindow.cpp 5 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 5 We move on to the slots of \c MainWindow, starting with \c addFiles(): - \snippet examples/phonon/musicplayer/mainwindow.cpp 6 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 6 In the \c addFiles() slot, we add files selected by the user to the \c sources list. We then set the first source selected on the @@ -169,7 +169,7 @@ stateChanged() signal. The \c stateChanged() slot is connected to this signal. - \snippet examples/phonon/musicplayer/mainwindow.cpp 9 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 9 The \l{Phonon::MediaObject::}{errorString()} function gives a description of the error that is suitable for users of a Phonon @@ -177,7 +177,7 @@ helps us determine whether it is possible to try to play the same file again. - \snippet examples/phonon/musicplayer/mainwindow.cpp 10 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 10 We update the GUI when the playback state changes, i.e., when it starts, pauses, stops, or resumes. @@ -188,26 +188,26 @@ The \c tick() slot is connected to a \l{Phonon::}{MediaObject} signal which is emitted when the playback position changes: - \snippet examples/phonon/musicplayer/mainwindow.cpp 11 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 11 The \c time is given in milliseconds. When the table is clicked on with the mouse, \c tableClick() is invoked: - \snippet examples/phonon/musicplayer/mainwindow.cpp 12 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 12 Since we stop the media object, we first check whether it is currently playing. \c row contains the row in the table that was clicked upon; the indices of \c sources follows the table, so we can simply use \c row to find the new source. - \snippet examples/phonon/musicplayer/mainwindow.cpp 13 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 13 When the media source changes, we simply need to select the corresponding row in the table. - \snippet examples/phonon/musicplayer/mainwindow.cpp 14 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 14 When \c metaStateChanged() is invoked, \c metaInformationProvider has resolved the meta data for its current @@ -220,7 +220,7 @@ music table. A file might not contain the meta data requested, in which case an empty string is returned. - \snippet examples/phonon/musicplayer/mainwindow.cpp 15 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 15 If we have media sources in \c sources of which meta information is not resolved, we set a new source on the \c @@ -229,7 +229,7 @@ We move on to the \c aboutToFinish() slot: - \snippet examples/phonon/musicplayer/mainwindow.cpp 16 + \snippet examples/phonon/qmusicplayer/mainwindow.cpp 16 When a file is finished playing, the Music Player will move on and play the next file in the table. This slot is connected to the @@ -244,5 +244,5 @@ \l{QCoreApplication::}{setApplicationName()}. This is because D-Bus, which is used by Phonon on Linux systems, demands this. - \snippet examples/phonon/musicplayer/main.cpp 1 + \snippet examples/phonon/qmusicplayer/main.cpp 1 */ diff --git a/doc/src/getting-started/demos.qdoc b/doc/src/getting-started/demos.qdoc index 532715e..8f2829a 100644 --- a/doc/src/getting-started/demos.qdoc +++ b/doc/src/getting-started/demos.qdoc @@ -157,7 +157,7 @@ \section1 Phonon \list - \o \l{demos/mediaplayer}{Media Player} demonstrates how the \l{Phonon Module} can be + \o \l{demos/qmediaplayer}{Media Player} demonstrates how the \l{Phonon Module} can be used to implement a basic media player application. \endlist diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index 30dae88..2ad730a7 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -827,7 +827,7 @@ \list \o \l{phonon/capabilities}{Capabilities}\raisedaster - \o \l{phonon/musicplayer}{Music Player}\raisedaster + \o \l{phonon/qmusicplayer}{Music Player}\raisedaster \endlist */ diff --git a/examples/network/ftp/ftp.pro b/examples/network/ftp/ftp.pro deleted file mode 100644 index ce2a97b..0000000 --- a/examples/network/ftp/ftp.pro +++ /dev/null @@ -1,20 +0,0 @@ -HEADERS = ftpwindow.h -SOURCES = ftpwindow.cpp \ - main.cpp -RESOURCES += ftp.qrc -QT += network - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/network/ftp -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS ftp.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/network/ftp -INSTALLS += target sources - -symbian { - TARGET.UID3 = 0xA000A648 - include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - HEADERS += sym_iap_util.h - INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE - TARGET.CAPABILITY="NetworkServices ReadUserData WriteUserData" - LIBS+=-lesock -lcommdb -linsock # For IAP selection -} diff --git a/examples/network/ftp/ftp.qrc b/examples/network/ftp/ftp.qrc deleted file mode 100644 index b598ab8..0000000 --- a/examples/network/ftp/ftp.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - images/cdtoparent.png - images/dir.png - images/file.png - - diff --git a/examples/network/ftp/ftpwindow.cpp b/examples/network/ftp/ftpwindow.cpp deleted file mode 100644 index f3fc52b..0000000 --- a/examples/network/ftp/ftpwindow.cpp +++ /dev/null @@ -1,379 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "ftpwindow.h" - -#ifdef Q_OS_SYMBIAN -#include "sym_iap_util.h" -#endif - -FtpWindow::FtpWindow(QWidget *parent) - : QDialog(parent), ftp(0) -{ - ftpServerLabel = new QLabel(tr("Ftp &server:")); - ftpServerLineEdit = new QLineEdit("ftp.qt.nokia.com"); - ftpServerLabel->setBuddy(ftpServerLineEdit); - - statusLabel = new QLabel(tr("Please enter the name of an FTP server.")); -#ifdef Q_OS_SYMBIAN - // Use word wrapping to fit the text on screen - statusLabel->setWordWrap( true ); -#endif - - fileList = new QTreeWidget; - fileList->setEnabled(false); - fileList->setRootIsDecorated(false); - fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time")); - fileList->header()->setStretchLastSection(false); - - connectButton = new QPushButton(tr("Connect")); - connectButton->setDefault(true); - - cdToParentButton = new QPushButton; - cdToParentButton->setIcon(QPixmap(":/images/cdtoparent.png")); - cdToParentButton->setEnabled(false); - - downloadButton = new QPushButton(tr("Download")); - downloadButton->setEnabled(false); - - quitButton = new QPushButton(tr("Quit")); - - buttonBox = new QDialogButtonBox; - buttonBox->addButton(downloadButton, QDialogButtonBox::ActionRole); - buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); - - progressDialog = new QProgressDialog(this); - - connect(fileList, SIGNAL(itemActivated(QTreeWidgetItem *, int)), - this, SLOT(processItem(QTreeWidgetItem *, int))); - connect(fileList, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), - this, SLOT(enableDownloadButton())); - connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload())); - connect(connectButton, SIGNAL(clicked()), this, SLOT(connectOrDisconnect())); - connect(cdToParentButton, SIGNAL(clicked()), this, SLOT(cdToParent())); - connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile())); - connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); - - QHBoxLayout *topLayout = new QHBoxLayout; - topLayout->addWidget(ftpServerLabel); - topLayout->addWidget(ftpServerLineEdit); -#ifndef Q_OS_SYMBIAN - topLayout->addWidget(cdToParentButton); - topLayout->addWidget(connectButton); -#else - // Make app better lookin on small screen - QHBoxLayout *topLayout2 = new QHBoxLayout; - topLayout2->addWidget(cdToParentButton); - topLayout2->addWidget(connectButton); -#endif - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addLayout(topLayout); -#ifdef Q_OS_SYMBIAN - // Make app better lookin on small screen - mainLayout->addLayout(topLayout2); -#endif - mainLayout->addWidget(fileList); - mainLayout->addWidget(statusLabel); - mainLayout->addWidget(buttonBox); - setLayout(mainLayout); - -#ifdef Q_OS_SYMBIAN - bDefaultIapSet = false; -#endif - - setWindowTitle(tr("FTP")); -} - -QSize FtpWindow::sizeHint() const -{ - return QSize(500, 300); -} - -//![0] -void FtpWindow::connectOrDisconnect() -{ -#ifdef Q_OS_SYMBIAN - if(!bDefaultIapSet) { - qt_SetDefaultIap(); - bDefaultIapSet = true; - } -#endif - if (ftp) { - ftp->abort(); - ftp->deleteLater(); - ftp = 0; -//![0] - fileList->setEnabled(false); - cdToParentButton->setEnabled(false); - downloadButton->setEnabled(false); - connectButton->setEnabled(true); - connectButton->setText(tr("Connect")); -#ifndef QT_NO_CURSOR - setCursor(Qt::ArrowCursor); -#endif - statusLabel->setText(tr("Please enter the name of an FTP server.")); - return; - } - -#ifndef QT_NO_CURSOR - setCursor(Qt::WaitCursor); -#endif - -//![1] - ftp = new QFtp(this); - connect(ftp, SIGNAL(commandFinished(int, bool)), - this, SLOT(ftpCommandFinished(int, bool))); - connect(ftp, SIGNAL(listInfo(const QUrlInfo &)), - this, SLOT(addToList(const QUrlInfo &))); - connect(ftp, SIGNAL(dataTransferProgress(qint64, qint64)), - this, SLOT(updateDataTransferProgress(qint64, qint64))); - - fileList->clear(); - currentPath.clear(); - isDirectory.clear(); -//![1] - -//![2] - QUrl url(ftpServerLineEdit->text()); - if (!url.isValid() || url.scheme().toLower() != QLatin1String("ftp")) { - ftp->connectToHost(ftpServerLineEdit->text(), 21); - ftp->login(); - } else { - ftp->connectToHost(url.host(), url.port(21)); - - if (!url.userName().isEmpty()) - ftp->login(QUrl::fromPercentEncoding(url.userName().toLatin1()), url.password()); - else - ftp->login(); - if (!url.path().isEmpty()) - ftp->cd(url.path()); - } -//![2] - - fileList->setEnabled(true); - connectButton->setEnabled(false); - connectButton->setText(tr("Disconnect")); - statusLabel->setText(tr("Connecting to FTP server %1...") - .arg(ftpServerLineEdit->text())); -} - -//![3] -void FtpWindow::downloadFile() -{ - QString fileName = fileList->currentItem()->text(0); -//![3] -// - if (QFile::exists(fileName)) { - QMessageBox::information(this, tr("FTP"), - tr("There already exists a file called %1 in " - "the current directory.") - .arg(fileName)); - return; - } - -//![4] - file = new QFile(fileName); - if (!file->open(QIODevice::WriteOnly)) { - QMessageBox::information(this, tr("FTP"), - tr("Unable to save the file %1: %2.") - .arg(fileName).arg(file->errorString())); - delete file; - return; - } - - ftp->get(fileList->currentItem()->text(0), file); - - progressDialog->setLabelText(tr("Downloading %1...").arg(fileName)); - downloadButton->setEnabled(false); - progressDialog->exec(); -} -//![4] - -//![5] -void FtpWindow::cancelDownload() -{ - ftp->abort(); -} -//![5] - -//![6] -void FtpWindow::ftpCommandFinished(int, bool error) -{ -#ifndef QT_NO_CURSOR - setCursor(Qt::ArrowCursor); -#endif - - if (ftp->currentCommand() == QFtp::ConnectToHost) { - if (error) { - QMessageBox::information(this, tr("FTP"), - tr("Unable to connect to the FTP server " - "at %1. Please check that the host " - "name is correct.") - .arg(ftpServerLineEdit->text())); - connectOrDisconnect(); - return; - } - statusLabel->setText(tr("Logged onto %1.") - .arg(ftpServerLineEdit->text())); - fileList->setFocus(); - downloadButton->setDefault(true); - connectButton->setEnabled(true); - return; - } -//![6] - -//![7] - if (ftp->currentCommand() == QFtp::Login) - ftp->list(); -//![7] - -//![8] - if (ftp->currentCommand() == QFtp::Get) { - if (error) { - statusLabel->setText(tr("Canceled download of %1.") - .arg(file->fileName())); - file->close(); - file->remove(); - } else { - statusLabel->setText(tr("Downloaded %1 to current directory.") - .arg(file->fileName())); - file->close(); - } - delete file; - enableDownloadButton(); - progressDialog->hide(); -//![8] -//![9] - } else if (ftp->currentCommand() == QFtp::List) { - if (isDirectory.isEmpty()) { - fileList->addTopLevelItem(new QTreeWidgetItem(QStringList() << tr(""))); - fileList->setEnabled(false); - } - } -//![9] -} - -//![10] -void FtpWindow::addToList(const QUrlInfo &urlInfo) -{ - QTreeWidgetItem *item = new QTreeWidgetItem; - item->setText(0, urlInfo.name()); - item->setText(1, QString::number(urlInfo.size())); - item->setText(2, urlInfo.owner()); - item->setText(3, urlInfo.group()); - item->setText(4, urlInfo.lastModified().toString("MMM dd yyyy")); - - QPixmap pixmap(urlInfo.isDir() ? ":/images/dir.png" : ":/images/file.png"); - item->setIcon(0, pixmap); - - isDirectory[urlInfo.name()] = urlInfo.isDir(); - fileList->addTopLevelItem(item); - if (!fileList->currentItem()) { - fileList->setCurrentItem(fileList->topLevelItem(0)); - fileList->setEnabled(true); - } -} -//![10] - -//![11] -void FtpWindow::processItem(QTreeWidgetItem *item, int /*column*/) -{ - QString name = item->text(0); - if (isDirectory.value(name)) { - fileList->clear(); - isDirectory.clear(); - currentPath += "/" + name; - ftp->cd(name); - ftp->list(); - cdToParentButton->setEnabled(true); -#ifndef QT_NO_CURSOR - setCursor(Qt::WaitCursor); -#endif - return; - } -} -//![11] - -//![12] -void FtpWindow::cdToParent() -{ -#ifndef QT_NO_CURSOR - setCursor(Qt::WaitCursor); -#endif - fileList->clear(); - isDirectory.clear(); - currentPath = currentPath.left(currentPath.lastIndexOf('/')); - if (currentPath.isEmpty()) { - cdToParentButton->setEnabled(false); - ftp->cd("/"); - } else { - ftp->cd(currentPath); - } - ftp->list(); -} -//![12] - -//![13] -void FtpWindow::updateDataTransferProgress(qint64 readBytes, - qint64 totalBytes) -{ - progressDialog->setMaximum(totalBytes); - progressDialog->setValue(readBytes); -} -//![13] - -//![14] -void FtpWindow::enableDownloadButton() -{ - QTreeWidgetItem *current = fileList->currentItem(); - if (current) { - QString currentFile = current->text(0); - downloadButton->setEnabled(!isDirectory.value(currentFile)); - } else { - downloadButton->setEnabled(false); - } -} -//![14] - diff --git a/examples/network/ftp/ftpwindow.h b/examples/network/ftp/ftpwindow.h deleted file mode 100644 index f92c36a..0000000 --- a/examples/network/ftp/ftpwindow.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef FTPWINDOW_H -#define FTPWINDOW_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QDialogButtonBox; -class QFile; -class QFtp; -class QLabel; -class QLineEdit; -class QTreeWidget; -class QTreeWidgetItem; -class QProgressDialog; -class QPushButton; -class QUrlInfo; -QT_END_NAMESPACE - -class FtpWindow : public QDialog -{ - Q_OBJECT - -public: - FtpWindow(QWidget *parent = 0); - QSize sizeHint() const; - -//![0] -private slots: - void connectOrDisconnect(); - void downloadFile(); - void cancelDownload(); - - void ftpCommandFinished(int commandId, bool error); - void addToList(const QUrlInfo &urlInfo); - void processItem(QTreeWidgetItem *item, int column); - void cdToParent(); - void updateDataTransferProgress(qint64 readBytes, - qint64 totalBytes); - void enableDownloadButton(); -//![0] - -private: - QLabel *ftpServerLabel; - QLineEdit *ftpServerLineEdit; - QLabel *statusLabel; - QTreeWidget *fileList; - QPushButton *cdToParentButton; - QPushButton *connectButton; - QPushButton *downloadButton; - QPushButton *quitButton; - QDialogButtonBox *buttonBox; - QProgressDialog *progressDialog; - -//![1] - QHash isDirectory; - QString currentPath; - QFtp *ftp; - QFile *file; - -#ifdef Q_OS_SYMBIAN - bool bDefaultIapSet; -#endif -//![1] -}; - -#endif diff --git a/examples/network/ftp/images/cdtoparent.png b/examples/network/ftp/images/cdtoparent.png deleted file mode 100644 index 24b6180..0000000 Binary files a/examples/network/ftp/images/cdtoparent.png and /dev/null differ diff --git a/examples/network/ftp/images/dir.png b/examples/network/ftp/images/dir.png deleted file mode 100644 index 0ce5ae7..0000000 Binary files a/examples/network/ftp/images/dir.png and /dev/null differ diff --git a/examples/network/ftp/images/file.png b/examples/network/ftp/images/file.png deleted file mode 100644 index be6c530..0000000 Binary files a/examples/network/ftp/images/file.png and /dev/null differ diff --git a/examples/network/ftp/main.cpp b/examples/network/ftp/main.cpp deleted file mode 100644 index d44ccd7..0000000 --- a/examples/network/ftp/main.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "ftpwindow.h" - -#ifdef Q_OS_SYMBIAN -#include -#include -#endif - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(ftp); -#ifdef Q_OS_SYMBIAN - // Change current directory from default private to c:\data - // in order that user can access the downloaded content - QDir::setCurrent( "c:\\data" ); -#endif - QApplication app(argc, argv); - FtpWindow ftpWin; -#ifdef Q_OS_SYMBIAN - // Make application better looking and more usable on small screen - ftpWin.showMaximized(); -#else - ftpWin.show(); -#endif - return ftpWin.exec(); -} diff --git a/examples/network/ftp/sym_iap_util.h b/examples/network/ftp/sym_iap_util.h deleted file mode 100644 index ebeae0a..0000000 --- a/examples/network/ftp/sym_iap_util.h +++ /dev/null @@ -1,510 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QSYM_IAP_UTIL_H -#define QSYM_IAP_UTIL_H - -// Symbian -#include -#include -#include -#include -#include -#include -#include - -// OpenC -#include -#include - -//Qt -#include -#include -//#include - -_LIT(KIapNameSetting, "IAP\\Name"); // text - mandatory -_LIT(KIapDialogPref, "IAP\\DialogPref"); // TUnit32 - optional -_LIT(KIapService, "IAP\\IAPService"); // TUnit32 - mandatory -_LIT(KIapServiceType, "IAP\\IAPServiceType"); // text - mandatory -_LIT(KIapBearer, "IAP\\IAPBearer"); // TUint32 - optional -_LIT(KIapBearerType, "IAP\\IAPBearerType"); // text - optional -_LIT(KIapNetwork, "IAP\\IAPNetwork"); // TUint32 - optional - -const QLatin1String qtOrganizationTag("Trolltech"); -const QLatin1String qtNetworkModuleTag("QtNetwork"); -const QLatin1String iapGroupTag("IAP"); -const QLatin1String iapNamesArrayTag("Names"); -const QLatin1String iapNameItemTag("Name"); - -static QTextCodec *utf16LETextCodec = 0; - -void clearIapNamesSettings(QSettings &settings) { - settings.beginGroup(qtNetworkModuleTag); - settings.beginGroup(iapGroupTag); - settings.remove(iapNamesArrayTag); - settings.endGroup(); - settings.endGroup(); -} - -void writeIapNamesSettings(QSettings &settings, const QStringList& iapNames) { - clearIapNamesSettings(settings); - settings.beginGroup(qtNetworkModuleTag); - settings.beginGroup(iapGroupTag); - settings.beginWriteArray(iapNamesArrayTag); - for (int index = 0; index < iapNames.size(); ++index) { - settings.setArrayIndex(index); - settings.setValue(iapNameItemTag, iapNames.at(index)); - } - settings.endArray(); - settings.endGroup(); - settings.endGroup(); -} - -void readIapNamesSettings(QSettings &settings, QStringList& iapNames) { - settings.beginGroup(qtNetworkModuleTag); - settings.beginGroup(iapGroupTag); - int last = settings.beginReadArray(iapNamesArrayTag); - for (int index = 0; index < last; ++index) { - settings.setArrayIndex(index); - iapNames.append(settings.value(iapNameItemTag).toString()); - } - settings.endArray(); - settings.endGroup(); - settings.endGroup(); -} - -static QString qt_TNameToQString(TName data) { - if(utf16LETextCodec == 0) - utf16LETextCodec = QTextCodec::codecForName("UTF-16LE"); - - QByteArray tmpByteArray = QByteArray::fromRawData((char*)(data.PtrZ()), data.Length() * 2); - return utf16LETextCodec->toUnicode(tmpByteArray); -} - -static QString qt_InterfaceInfoL() -{ - QString output; - - TBuf8<512> buffer; - TBuf<128> t; - TAutoClose ss; - User::LeaveIfError(ss.iObj.Connect()); - ss.PushL(); - - TAutoClose sock; - User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); - sock.PushL(); - - User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl)); - - TProtocolDesc in; - User::LeaveIfError(sock.iObj.Info(in)); - printf("EPOC32 IP Configuration TCPIP Version %d.%d.%d\n", in.iVersion.iMajor, in.iVersion.iMinor, in.iVersion.iBuild); - - TPckgBuf info, next; - - TInt res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, info); - if(res!=KErrNone) - User::Leave(res); - TInt count = 0; - while(res==KErrNone) { - res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, next); - - if(info().iName != _L("") && info().iName != _L("loop6") && info().iName != _L("loop4")) { - printf("Interface %d\n", count++); - - printf("Name \"%s\"\n", qt_TNameToQString(info().iName).toLatin1().data()); - printf("NIF tag \"%s\"\n", qt_TNameToQString(info().iTag).toLatin1().data()); - - printf("State "); - switch (info().iState) - { - case EIfPending: - printf("pending\n"); - break; - case EIfUp: - printf("up\n"); - break; - case EIfBusy: - printf("busy\n"); - break; - default: - printf("down\n"); - break; - } - - printf("Mtu %d\n", info().iMtu); - printf("Speed Metric %d\n", info().iSpeedMetric); - - printf("Features:"); - info().iFeatures & KIfIsLoopback ? printf(" loopback") : printf(""); - info().iFeatures & KIfIsDialup ? printf(" dialup") : printf(""); - info().iFeatures & KIfIsPointToPoint ? printf(" pointtopoint") : printf(""); - info().iFeatures & KIfCanBroadcast ? printf(" canbroadcast") : printf(""); - info().iFeatures & KIfCanMulticast ? printf(" canmulticast") : printf(""); - info().iFeatures & KIfCanSetMTU ? printf(" cansetmtu") : printf(""); - info().iFeatures & KIfHasHardwareAddr ? printf(" hardwareaddr") : printf(""); - info().iFeatures & KIfCanSetHardwareAddr ? printf(" cansethardwareaddr") : printf(""); - printf("\n"); - - TName address; - info().iAddress.Output(address); - printf("Addr: %s\n", qt_TNameToQString(address).toLatin1().data()); - - if(info().iAddress.IsLinkLocal()) { - printf(" -link local\n"); - } else if(info().iAddress.IsSiteLocal()) { - printf(" -site local\n"); - } else { - printf(" -global\n"); - } - - info().iNetMask.Output(address); - printf("Netmask %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iBrdAddr.Output(address); - printf("Broadcast address %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iDefGate.Output(address); - printf("Gatew: %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iNameSer1.Output(address); - printf("DNS 1: %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iNameSer2.Output(address); - printf("DNS 2: %s\n", qt_TNameToQString(address).toLatin1().data()); - - if (info().iHwAddr.Family() != KAFUnspec) { - printf("Hardware address "); - TUint j; - for(j = sizeof(SSockAddr) ; j < sizeof(SSockAddr) + 6 ; ++j) { - if(j < (TUint)info().iHwAddr.Length()) { - printf("%02X", info().iHwAddr[j]); - } else { - printf("??"); - } - if(j < sizeof(SSockAddr) + 5) - printf("-"); - else - printf("\n"); - } - } - } - if(res == KErrNone) { - info = next; - printf("\n"); - } else { - printf("\n"); - } - } - - sock.Pop(); - ss.Pop(); - - return output; -} - -static QString qt_RouteInfoL() { - QString output; - TAutoClose ss; - User::LeaveIfError(ss.iObj.Connect()); - ss.PushL(); - - TAutoClose sock; - User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); - sock.PushL(); - - TSoInetRouteInfo routeInfo; - TPckg routeInfoPkg(routeInfo); - - TName destAddr; - TName netMask; - TName gateway; - TName ifAddr; - - // Begins enumeration of routes by setting this option - User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumRoutes, KSolInetRtCtrl)); - - // The TSoInetRouteInfo contains information for a new route each time GetOpt returns KErrNone - for(TInt i = 0; sock.iObj.GetOpt(KSoInetNextRoute, KSolInetRtCtrl, routeInfoPkg) == KErrNone ; i++) - { - // Extract the destination and netmask - routeInfo.iDstAddr.Output(destAddr); - routeInfo.iNetMask.Output(netMask); - routeInfo.iGateway.Output(gateway); - routeInfo.iIfAddr.Output(ifAddr); -/* - if(destAddr.Length() <= 2) - continue; - - if(netMask.Find(_L("255.255.255.255")) != KErrNotFound - || netMask.Find(_L("0.0.0.0")) != KErrNotFound - || netMask.Find(_L("ffff:ffff:ffff:ffff")) != KErrNotFound) - continue; -*/ - printf("Route Info #[%i]\n", i); - printf("DstAddr %s\n", qt_TNameToQString(destAddr).toLatin1().data()); - printf("NetMask %s\n", qt_TNameToQString(netMask).toLatin1().data()); - printf("Gateway %s\n", qt_TNameToQString(gateway).toLatin1().data()); - printf("IfAddr %s\n", qt_TNameToQString(ifAddr).toLatin1().data()); - printf("\n"); - } - - sock.Pop(); - ss.Pop(); - - return output; -} - -QString qt_TDesC2QStringL(const TDesC& aDescriptor) -{ -#ifdef QT_NO_UNICODE - return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length()); -#else - return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length()); -#endif -} - -static bool qt_SetDefaultIapName(const QString &iapName, int &error) { - struct ifreq ifReq; - // clear structure - memset(&ifReq, 0, sizeof(struct ifreq)); - // set IAP name value - // make sure it is in UTF8 - strcpy(ifReq.ifr_name, iapName.toUtf8().data()); - - if(setdefaultif(&ifReq) == 0) { - // OK - error = 0; - return true; - } else { - error = errno; - return false; - } - -} -static bool qt_SetDefaultSnapId(const int snapId, int &error) { - struct ifreq ifReq; - // clear structure - memset(&ifReq, 0, sizeof(struct ifreq)); - // set SNAP ID value - ifReq.ifr_ifru.snap_id = snapId; - - if(setdefaultif(&ifReq) == 0) { - // OK - error = 0; - return true; - } else { - error = errno; - return false; - } - -} - -static void qt_SaveIapName(QSettings& settings, QStringList& iapNames, QString& iapNameValue) { - if(iapNames.contains(iapNameValue) && iapNames.first() == iapNameValue) { - // no need to update - } else { - if(iapNameValue != QString("Easy WLAN")) { - // new selection alway on top - iapNames.removeAll(iapNameValue); - iapNames.prepend(iapNameValue); - writeIapNamesSettings(settings, iapNames); - } else { - // Unbeliveable ... if IAP dodn't exist before - // no matter what you choose from IAP selection list - // you will get "Easy WLAN" as IAP name value - - // somehow commsdb is not in sync - } - } -} - -static QString qt_OfferIapDialog() { - TBuf8<256> iapName; - - RSocketServ socketServ; - CleanupClosePushL(socketServ); - - RConnection connection; - CleanupClosePushL(connection); - - socketServ.Connect(); - connection.Open(socketServ); - connection.Start(); - - connection.GetDesSetting(TPtrC(KIapNameSetting), iapName); - - //connection.Stop(); - - iapName.ZeroTerminate(); - QString strIapName((char*)iapName.Ptr()); - - int error = 0; - if(!qt_SetDefaultIapName(strIapName, error)) { - //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); - strIapName = QString(""); - } - - CleanupStack::PopAndDestroy(&connection); - CleanupStack::PopAndDestroy(&socketServ); - - return strIapName; -} - -static QString qt_CheckForActiveConnection() { - TUint count; - - RSocketServ serv; - CleanupClosePushL(serv); - - RConnection conn; - CleanupClosePushL(conn); - - serv.Connect(); - conn.Open(serv); - - TConnectionInfoBuf connInfo; - - TBuf8<256> iapName; - TBuf8<256> iapServiceType; - - QString strIapName; - - if (conn.EnumerateConnections(count) == KErrNone) { - if(count > 0) { - for (TUint i = 1; i <= count; i++) { - if (conn.GetConnectionInfo(i, connInfo) == KErrNone) { - RConnection tempConn; - CleanupClosePushL(tempConn); - tempConn.Open(serv); - if (tempConn.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { - tempConn.GetDesSetting(TPtrC(KIapNameSetting), iapName); - tempConn.GetDesSetting(TPtrC(KIapServiceType), iapServiceType); - //tempConn.Stop(); - iapName.ZeroTerminate(); - iapServiceType.ZeroTerminate(); - -// if(iapServiceType.Find(_L8("LANService")) != KErrNotFound) { -// activeLanConnectionFound = ETrue; -// break; -// } - strIapName = QString((char*)iapName.Ptr()); - int error = 0; - if(!qt_SetDefaultIapName(strIapName, error)) { - //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); - strIapName = QString(""); - } - - CleanupStack::PopAndDestroy(&tempConn); - break; - } - } - } - } - } - - //conn.Stop(); - - CleanupStack::PopAndDestroy(&conn); - CleanupStack::PopAndDestroy(&serv); - - return strIapName; -} - -static QString qt_CheckSettingsForConnection(QStringList& iapNames) { - QString strIapName; - for(int index = 0; index < iapNames.size(); ++index) { - strIapName = iapNames.at(index); - int error = 0; - if(!qt_SetDefaultIapName(strIapName, error)) { - //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); - strIapName = QString(""); - } else { - return strIapName; - } - } - return strIapName; -} - -static void qt_SetDefaultIapL() -{ - // settings @ /c/data/.config/Trolltech.com - QSettings settings(QSettings::UserScope, qtOrganizationTag); - // populate iap name list - QStringList iapNames; - readIapNamesSettings(settings, iapNames); - - QString iapNameValue; - - iapNameValue = qt_CheckForActiveConnection(); - - if(!iapNameValue.isEmpty()) { - qt_SaveIapName(settings, iapNames, iapNameValue); - return; - } - - iapNameValue = qt_CheckSettingsForConnection(iapNames); - - if(!iapNameValue.isEmpty()) { - qt_SaveIapName(settings, iapNames, iapNameValue); - return; - } - - /* - * no active LAN connections yet - * no IAP in settings - * offer IAP dialog to user - */ - iapNameValue = qt_OfferIapDialog(); - qt_SaveIapName(settings, iapNames, iapNameValue); - return; - -} - -static int qt_SetDefaultIap() -{ - TRAPD(err1, qt_SetDefaultIapL()); -// TRAPD(err2, qt_InterfaceInfoL()); -// TRAPD(err3, qt_RouteInfoL()); - return err1; -} - -#endif // QSYM_IAP_UTIL_H diff --git a/examples/network/network.pro b/examples/network/network.pro index 38cdae8..0849271 100644 --- a/examples/network/network.pro +++ b/examples/network/network.pro @@ -6,7 +6,7 @@ SUBDIRS = blockingfortuneclient \ downloadmanager \ fortuneclient \ fortuneserver \ - ftp \ + qftp \ http \ loopback \ threadedfortuneserver \ @@ -16,7 +16,7 @@ SUBDIRS = blockingfortuneclient \ # no QProcess !vxworks:!qnx:SUBDIRS += network-chat -symbian: SUBDIRS = ftp +symbian: SUBDIRS = qftp contains(QT_CONFIG, openssl):SUBDIRS += securesocketclient diff --git a/examples/network/qftp/ftp.qrc b/examples/network/qftp/ftp.qrc new file mode 100644 index 0000000..b598ab8 --- /dev/null +++ b/examples/network/qftp/ftp.qrc @@ -0,0 +1,7 @@ + + + images/cdtoparent.png + images/dir.png + images/file.png + + diff --git a/examples/network/qftp/ftpwindow.cpp b/examples/network/qftp/ftpwindow.cpp new file mode 100644 index 0000000..f3fc52b --- /dev/null +++ b/examples/network/qftp/ftpwindow.cpp @@ -0,0 +1,379 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "ftpwindow.h" + +#ifdef Q_OS_SYMBIAN +#include "sym_iap_util.h" +#endif + +FtpWindow::FtpWindow(QWidget *parent) + : QDialog(parent), ftp(0) +{ + ftpServerLabel = new QLabel(tr("Ftp &server:")); + ftpServerLineEdit = new QLineEdit("ftp.qt.nokia.com"); + ftpServerLabel->setBuddy(ftpServerLineEdit); + + statusLabel = new QLabel(tr("Please enter the name of an FTP server.")); +#ifdef Q_OS_SYMBIAN + // Use word wrapping to fit the text on screen + statusLabel->setWordWrap( true ); +#endif + + fileList = new QTreeWidget; + fileList->setEnabled(false); + fileList->setRootIsDecorated(false); + fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time")); + fileList->header()->setStretchLastSection(false); + + connectButton = new QPushButton(tr("Connect")); + connectButton->setDefault(true); + + cdToParentButton = new QPushButton; + cdToParentButton->setIcon(QPixmap(":/images/cdtoparent.png")); + cdToParentButton->setEnabled(false); + + downloadButton = new QPushButton(tr("Download")); + downloadButton->setEnabled(false); + + quitButton = new QPushButton(tr("Quit")); + + buttonBox = new QDialogButtonBox; + buttonBox->addButton(downloadButton, QDialogButtonBox::ActionRole); + buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); + + progressDialog = new QProgressDialog(this); + + connect(fileList, SIGNAL(itemActivated(QTreeWidgetItem *, int)), + this, SLOT(processItem(QTreeWidgetItem *, int))); + connect(fileList, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), + this, SLOT(enableDownloadButton())); + connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload())); + connect(connectButton, SIGNAL(clicked()), this, SLOT(connectOrDisconnect())); + connect(cdToParentButton, SIGNAL(clicked()), this, SLOT(cdToParent())); + connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile())); + connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); + + QHBoxLayout *topLayout = new QHBoxLayout; + topLayout->addWidget(ftpServerLabel); + topLayout->addWidget(ftpServerLineEdit); +#ifndef Q_OS_SYMBIAN + topLayout->addWidget(cdToParentButton); + topLayout->addWidget(connectButton); +#else + // Make app better lookin on small screen + QHBoxLayout *topLayout2 = new QHBoxLayout; + topLayout2->addWidget(cdToParentButton); + topLayout2->addWidget(connectButton); +#endif + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(topLayout); +#ifdef Q_OS_SYMBIAN + // Make app better lookin on small screen + mainLayout->addLayout(topLayout2); +#endif + mainLayout->addWidget(fileList); + mainLayout->addWidget(statusLabel); + mainLayout->addWidget(buttonBox); + setLayout(mainLayout); + +#ifdef Q_OS_SYMBIAN + bDefaultIapSet = false; +#endif + + setWindowTitle(tr("FTP")); +} + +QSize FtpWindow::sizeHint() const +{ + return QSize(500, 300); +} + +//![0] +void FtpWindow::connectOrDisconnect() +{ +#ifdef Q_OS_SYMBIAN + if(!bDefaultIapSet) { + qt_SetDefaultIap(); + bDefaultIapSet = true; + } +#endif + if (ftp) { + ftp->abort(); + ftp->deleteLater(); + ftp = 0; +//![0] + fileList->setEnabled(false); + cdToParentButton->setEnabled(false); + downloadButton->setEnabled(false); + connectButton->setEnabled(true); + connectButton->setText(tr("Connect")); +#ifndef QT_NO_CURSOR + setCursor(Qt::ArrowCursor); +#endif + statusLabel->setText(tr("Please enter the name of an FTP server.")); + return; + } + +#ifndef QT_NO_CURSOR + setCursor(Qt::WaitCursor); +#endif + +//![1] + ftp = new QFtp(this); + connect(ftp, SIGNAL(commandFinished(int, bool)), + this, SLOT(ftpCommandFinished(int, bool))); + connect(ftp, SIGNAL(listInfo(const QUrlInfo &)), + this, SLOT(addToList(const QUrlInfo &))); + connect(ftp, SIGNAL(dataTransferProgress(qint64, qint64)), + this, SLOT(updateDataTransferProgress(qint64, qint64))); + + fileList->clear(); + currentPath.clear(); + isDirectory.clear(); +//![1] + +//![2] + QUrl url(ftpServerLineEdit->text()); + if (!url.isValid() || url.scheme().toLower() != QLatin1String("ftp")) { + ftp->connectToHost(ftpServerLineEdit->text(), 21); + ftp->login(); + } else { + ftp->connectToHost(url.host(), url.port(21)); + + if (!url.userName().isEmpty()) + ftp->login(QUrl::fromPercentEncoding(url.userName().toLatin1()), url.password()); + else + ftp->login(); + if (!url.path().isEmpty()) + ftp->cd(url.path()); + } +//![2] + + fileList->setEnabled(true); + connectButton->setEnabled(false); + connectButton->setText(tr("Disconnect")); + statusLabel->setText(tr("Connecting to FTP server %1...") + .arg(ftpServerLineEdit->text())); +} + +//![3] +void FtpWindow::downloadFile() +{ + QString fileName = fileList->currentItem()->text(0); +//![3] +// + if (QFile::exists(fileName)) { + QMessageBox::information(this, tr("FTP"), + tr("There already exists a file called %1 in " + "the current directory.") + .arg(fileName)); + return; + } + +//![4] + file = new QFile(fileName); + if (!file->open(QIODevice::WriteOnly)) { + QMessageBox::information(this, tr("FTP"), + tr("Unable to save the file %1: %2.") + .arg(fileName).arg(file->errorString())); + delete file; + return; + } + + ftp->get(fileList->currentItem()->text(0), file); + + progressDialog->setLabelText(tr("Downloading %1...").arg(fileName)); + downloadButton->setEnabled(false); + progressDialog->exec(); +} +//![4] + +//![5] +void FtpWindow::cancelDownload() +{ + ftp->abort(); +} +//![5] + +//![6] +void FtpWindow::ftpCommandFinished(int, bool error) +{ +#ifndef QT_NO_CURSOR + setCursor(Qt::ArrowCursor); +#endif + + if (ftp->currentCommand() == QFtp::ConnectToHost) { + if (error) { + QMessageBox::information(this, tr("FTP"), + tr("Unable to connect to the FTP server " + "at %1. Please check that the host " + "name is correct.") + .arg(ftpServerLineEdit->text())); + connectOrDisconnect(); + return; + } + statusLabel->setText(tr("Logged onto %1.") + .arg(ftpServerLineEdit->text())); + fileList->setFocus(); + downloadButton->setDefault(true); + connectButton->setEnabled(true); + return; + } +//![6] + +//![7] + if (ftp->currentCommand() == QFtp::Login) + ftp->list(); +//![7] + +//![8] + if (ftp->currentCommand() == QFtp::Get) { + if (error) { + statusLabel->setText(tr("Canceled download of %1.") + .arg(file->fileName())); + file->close(); + file->remove(); + } else { + statusLabel->setText(tr("Downloaded %1 to current directory.") + .arg(file->fileName())); + file->close(); + } + delete file; + enableDownloadButton(); + progressDialog->hide(); +//![8] +//![9] + } else if (ftp->currentCommand() == QFtp::List) { + if (isDirectory.isEmpty()) { + fileList->addTopLevelItem(new QTreeWidgetItem(QStringList() << tr(""))); + fileList->setEnabled(false); + } + } +//![9] +} + +//![10] +void FtpWindow::addToList(const QUrlInfo &urlInfo) +{ + QTreeWidgetItem *item = new QTreeWidgetItem; + item->setText(0, urlInfo.name()); + item->setText(1, QString::number(urlInfo.size())); + item->setText(2, urlInfo.owner()); + item->setText(3, urlInfo.group()); + item->setText(4, urlInfo.lastModified().toString("MMM dd yyyy")); + + QPixmap pixmap(urlInfo.isDir() ? ":/images/dir.png" : ":/images/file.png"); + item->setIcon(0, pixmap); + + isDirectory[urlInfo.name()] = urlInfo.isDir(); + fileList->addTopLevelItem(item); + if (!fileList->currentItem()) { + fileList->setCurrentItem(fileList->topLevelItem(0)); + fileList->setEnabled(true); + } +} +//![10] + +//![11] +void FtpWindow::processItem(QTreeWidgetItem *item, int /*column*/) +{ + QString name = item->text(0); + if (isDirectory.value(name)) { + fileList->clear(); + isDirectory.clear(); + currentPath += "/" + name; + ftp->cd(name); + ftp->list(); + cdToParentButton->setEnabled(true); +#ifndef QT_NO_CURSOR + setCursor(Qt::WaitCursor); +#endif + return; + } +} +//![11] + +//![12] +void FtpWindow::cdToParent() +{ +#ifndef QT_NO_CURSOR + setCursor(Qt::WaitCursor); +#endif + fileList->clear(); + isDirectory.clear(); + currentPath = currentPath.left(currentPath.lastIndexOf('/')); + if (currentPath.isEmpty()) { + cdToParentButton->setEnabled(false); + ftp->cd("/"); + } else { + ftp->cd(currentPath); + } + ftp->list(); +} +//![12] + +//![13] +void FtpWindow::updateDataTransferProgress(qint64 readBytes, + qint64 totalBytes) +{ + progressDialog->setMaximum(totalBytes); + progressDialog->setValue(readBytes); +} +//![13] + +//![14] +void FtpWindow::enableDownloadButton() +{ + QTreeWidgetItem *current = fileList->currentItem(); + if (current) { + QString currentFile = current->text(0); + downloadButton->setEnabled(!isDirectory.value(currentFile)); + } else { + downloadButton->setEnabled(false); + } +} +//![14] + diff --git a/examples/network/qftp/ftpwindow.h b/examples/network/qftp/ftpwindow.h new file mode 100644 index 0000000..f92c36a --- /dev/null +++ b/examples/network/qftp/ftpwindow.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FTPWINDOW_H +#define FTPWINDOW_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QDialogButtonBox; +class QFile; +class QFtp; +class QLabel; +class QLineEdit; +class QTreeWidget; +class QTreeWidgetItem; +class QProgressDialog; +class QPushButton; +class QUrlInfo; +QT_END_NAMESPACE + +class FtpWindow : public QDialog +{ + Q_OBJECT + +public: + FtpWindow(QWidget *parent = 0); + QSize sizeHint() const; + +//![0] +private slots: + void connectOrDisconnect(); + void downloadFile(); + void cancelDownload(); + + void ftpCommandFinished(int commandId, bool error); + void addToList(const QUrlInfo &urlInfo); + void processItem(QTreeWidgetItem *item, int column); + void cdToParent(); + void updateDataTransferProgress(qint64 readBytes, + qint64 totalBytes); + void enableDownloadButton(); +//![0] + +private: + QLabel *ftpServerLabel; + QLineEdit *ftpServerLineEdit; + QLabel *statusLabel; + QTreeWidget *fileList; + QPushButton *cdToParentButton; + QPushButton *connectButton; + QPushButton *downloadButton; + QPushButton *quitButton; + QDialogButtonBox *buttonBox; + QProgressDialog *progressDialog; + +//![1] + QHash isDirectory; + QString currentPath; + QFtp *ftp; + QFile *file; + +#ifdef Q_OS_SYMBIAN + bool bDefaultIapSet; +#endif +//![1] +}; + +#endif diff --git a/examples/network/qftp/images/cdtoparent.png b/examples/network/qftp/images/cdtoparent.png new file mode 100644 index 0000000..24b6180 Binary files /dev/null and b/examples/network/qftp/images/cdtoparent.png differ diff --git a/examples/network/qftp/images/dir.png b/examples/network/qftp/images/dir.png new file mode 100644 index 0000000..0ce5ae7 Binary files /dev/null and b/examples/network/qftp/images/dir.png differ diff --git a/examples/network/qftp/images/file.png b/examples/network/qftp/images/file.png new file mode 100644 index 0000000..be6c530 Binary files /dev/null and b/examples/network/qftp/images/file.png differ diff --git a/examples/network/qftp/main.cpp b/examples/network/qftp/main.cpp new file mode 100644 index 0000000..d44ccd7 --- /dev/null +++ b/examples/network/qftp/main.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "ftpwindow.h" + +#ifdef Q_OS_SYMBIAN +#include +#include +#endif + +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(ftp); +#ifdef Q_OS_SYMBIAN + // Change current directory from default private to c:\data + // in order that user can access the downloaded content + QDir::setCurrent( "c:\\data" ); +#endif + QApplication app(argc, argv); + FtpWindow ftpWin; +#ifdef Q_OS_SYMBIAN + // Make application better looking and more usable on small screen + ftpWin.showMaximized(); +#else + ftpWin.show(); +#endif + return ftpWin.exec(); +} diff --git a/examples/network/qftp/qftp.pro b/examples/network/qftp/qftp.pro new file mode 100644 index 0000000..b3106c3 --- /dev/null +++ b/examples/network/qftp/qftp.pro @@ -0,0 +1,20 @@ +HEADERS = ftpwindow.h +SOURCES = ftpwindow.cpp \ + main.cpp +RESOURCES += ftp.qrc +QT += network + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/network/qftp +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro images +sources.path = $$[QT_INSTALL_EXAMPLES]/network/qftp +INSTALLS += target sources + +symbian { + TARGET.UID3 = 0xA000A648 + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + HEADERS += sym_iap_util.h + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + TARGET.CAPABILITY="NetworkServices ReadUserData WriteUserData" + LIBS+=-lesock -lcommdb -linsock # For IAP selection +} diff --git a/examples/network/qftp/sym_iap_util.h b/examples/network/qftp/sym_iap_util.h new file mode 100644 index 0000000..ebeae0a --- /dev/null +++ b/examples/network/qftp/sym_iap_util.h @@ -0,0 +1,510 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QSYM_IAP_UTIL_H +#define QSYM_IAP_UTIL_H + +// Symbian +#include +#include +#include +#include +#include +#include +#include + +// OpenC +#include +#include + +//Qt +#include +#include +//#include + +_LIT(KIapNameSetting, "IAP\\Name"); // text - mandatory +_LIT(KIapDialogPref, "IAP\\DialogPref"); // TUnit32 - optional +_LIT(KIapService, "IAP\\IAPService"); // TUnit32 - mandatory +_LIT(KIapServiceType, "IAP\\IAPServiceType"); // text - mandatory +_LIT(KIapBearer, "IAP\\IAPBearer"); // TUint32 - optional +_LIT(KIapBearerType, "IAP\\IAPBearerType"); // text - optional +_LIT(KIapNetwork, "IAP\\IAPNetwork"); // TUint32 - optional + +const QLatin1String qtOrganizationTag("Trolltech"); +const QLatin1String qtNetworkModuleTag("QtNetwork"); +const QLatin1String iapGroupTag("IAP"); +const QLatin1String iapNamesArrayTag("Names"); +const QLatin1String iapNameItemTag("Name"); + +static QTextCodec *utf16LETextCodec = 0; + +void clearIapNamesSettings(QSettings &settings) { + settings.beginGroup(qtNetworkModuleTag); + settings.beginGroup(iapGroupTag); + settings.remove(iapNamesArrayTag); + settings.endGroup(); + settings.endGroup(); +} + +void writeIapNamesSettings(QSettings &settings, const QStringList& iapNames) { + clearIapNamesSettings(settings); + settings.beginGroup(qtNetworkModuleTag); + settings.beginGroup(iapGroupTag); + settings.beginWriteArray(iapNamesArrayTag); + for (int index = 0; index < iapNames.size(); ++index) { + settings.setArrayIndex(index); + settings.setValue(iapNameItemTag, iapNames.at(index)); + } + settings.endArray(); + settings.endGroup(); + settings.endGroup(); +} + +void readIapNamesSettings(QSettings &settings, QStringList& iapNames) { + settings.beginGroup(qtNetworkModuleTag); + settings.beginGroup(iapGroupTag); + int last = settings.beginReadArray(iapNamesArrayTag); + for (int index = 0; index < last; ++index) { + settings.setArrayIndex(index); + iapNames.append(settings.value(iapNameItemTag).toString()); + } + settings.endArray(); + settings.endGroup(); + settings.endGroup(); +} + +static QString qt_TNameToQString(TName data) { + if(utf16LETextCodec == 0) + utf16LETextCodec = QTextCodec::codecForName("UTF-16LE"); + + QByteArray tmpByteArray = QByteArray::fromRawData((char*)(data.PtrZ()), data.Length() * 2); + return utf16LETextCodec->toUnicode(tmpByteArray); +} + +static QString qt_InterfaceInfoL() +{ + QString output; + + TBuf8<512> buffer; + TBuf<128> t; + TAutoClose ss; + User::LeaveIfError(ss.iObj.Connect()); + ss.PushL(); + + TAutoClose sock; + User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); + sock.PushL(); + + User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl)); + + TProtocolDesc in; + User::LeaveIfError(sock.iObj.Info(in)); + printf("EPOC32 IP Configuration TCPIP Version %d.%d.%d\n", in.iVersion.iMajor, in.iVersion.iMinor, in.iVersion.iBuild); + + TPckgBuf info, next; + + TInt res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, info); + if(res!=KErrNone) + User::Leave(res); + TInt count = 0; + while(res==KErrNone) { + res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, next); + + if(info().iName != _L("") && info().iName != _L("loop6") && info().iName != _L("loop4")) { + printf("Interface %d\n", count++); + + printf("Name \"%s\"\n", qt_TNameToQString(info().iName).toLatin1().data()); + printf("NIF tag \"%s\"\n", qt_TNameToQString(info().iTag).toLatin1().data()); + + printf("State "); + switch (info().iState) + { + case EIfPending: + printf("pending\n"); + break; + case EIfUp: + printf("up\n"); + break; + case EIfBusy: + printf("busy\n"); + break; + default: + printf("down\n"); + break; + } + + printf("Mtu %d\n", info().iMtu); + printf("Speed Metric %d\n", info().iSpeedMetric); + + printf("Features:"); + info().iFeatures & KIfIsLoopback ? printf(" loopback") : printf(""); + info().iFeatures & KIfIsDialup ? printf(" dialup") : printf(""); + info().iFeatures & KIfIsPointToPoint ? printf(" pointtopoint") : printf(""); + info().iFeatures & KIfCanBroadcast ? printf(" canbroadcast") : printf(""); + info().iFeatures & KIfCanMulticast ? printf(" canmulticast") : printf(""); + info().iFeatures & KIfCanSetMTU ? printf(" cansetmtu") : printf(""); + info().iFeatures & KIfHasHardwareAddr ? printf(" hardwareaddr") : printf(""); + info().iFeatures & KIfCanSetHardwareAddr ? printf(" cansethardwareaddr") : printf(""); + printf("\n"); + + TName address; + info().iAddress.Output(address); + printf("Addr: %s\n", qt_TNameToQString(address).toLatin1().data()); + + if(info().iAddress.IsLinkLocal()) { + printf(" -link local\n"); + } else if(info().iAddress.IsSiteLocal()) { + printf(" -site local\n"); + } else { + printf(" -global\n"); + } + + info().iNetMask.Output(address); + printf("Netmask %s\n", qt_TNameToQString(address).toLatin1().data()); + + info().iBrdAddr.Output(address); + printf("Broadcast address %s\n", qt_TNameToQString(address).toLatin1().data()); + + info().iDefGate.Output(address); + printf("Gatew: %s\n", qt_TNameToQString(address).toLatin1().data()); + + info().iNameSer1.Output(address); + printf("DNS 1: %s\n", qt_TNameToQString(address).toLatin1().data()); + + info().iNameSer2.Output(address); + printf("DNS 2: %s\n", qt_TNameToQString(address).toLatin1().data()); + + if (info().iHwAddr.Family() != KAFUnspec) { + printf("Hardware address "); + TUint j; + for(j = sizeof(SSockAddr) ; j < sizeof(SSockAddr) + 6 ; ++j) { + if(j < (TUint)info().iHwAddr.Length()) { + printf("%02X", info().iHwAddr[j]); + } else { + printf("??"); + } + if(j < sizeof(SSockAddr) + 5) + printf("-"); + else + printf("\n"); + } + } + } + if(res == KErrNone) { + info = next; + printf("\n"); + } else { + printf("\n"); + } + } + + sock.Pop(); + ss.Pop(); + + return output; +} + +static QString qt_RouteInfoL() { + QString output; + TAutoClose ss; + User::LeaveIfError(ss.iObj.Connect()); + ss.PushL(); + + TAutoClose sock; + User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); + sock.PushL(); + + TSoInetRouteInfo routeInfo; + TPckg routeInfoPkg(routeInfo); + + TName destAddr; + TName netMask; + TName gateway; + TName ifAddr; + + // Begins enumeration of routes by setting this option + User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumRoutes, KSolInetRtCtrl)); + + // The TSoInetRouteInfo contains information for a new route each time GetOpt returns KErrNone + for(TInt i = 0; sock.iObj.GetOpt(KSoInetNextRoute, KSolInetRtCtrl, routeInfoPkg) == KErrNone ; i++) + { + // Extract the destination and netmask + routeInfo.iDstAddr.Output(destAddr); + routeInfo.iNetMask.Output(netMask); + routeInfo.iGateway.Output(gateway); + routeInfo.iIfAddr.Output(ifAddr); +/* + if(destAddr.Length() <= 2) + continue; + + if(netMask.Find(_L("255.255.255.255")) != KErrNotFound + || netMask.Find(_L("0.0.0.0")) != KErrNotFound + || netMask.Find(_L("ffff:ffff:ffff:ffff")) != KErrNotFound) + continue; +*/ + printf("Route Info #[%i]\n", i); + printf("DstAddr %s\n", qt_TNameToQString(destAddr).toLatin1().data()); + printf("NetMask %s\n", qt_TNameToQString(netMask).toLatin1().data()); + printf("Gateway %s\n", qt_TNameToQString(gateway).toLatin1().data()); + printf("IfAddr %s\n", qt_TNameToQString(ifAddr).toLatin1().data()); + printf("\n"); + } + + sock.Pop(); + ss.Pop(); + + return output; +} + +QString qt_TDesC2QStringL(const TDesC& aDescriptor) +{ +#ifdef QT_NO_UNICODE + return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length()); +#else + return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length()); +#endif +} + +static bool qt_SetDefaultIapName(const QString &iapName, int &error) { + struct ifreq ifReq; + // clear structure + memset(&ifReq, 0, sizeof(struct ifreq)); + // set IAP name value + // make sure it is in UTF8 + strcpy(ifReq.ifr_name, iapName.toUtf8().data()); + + if(setdefaultif(&ifReq) == 0) { + // OK + error = 0; + return true; + } else { + error = errno; + return false; + } + +} +static bool qt_SetDefaultSnapId(const int snapId, int &error) { + struct ifreq ifReq; + // clear structure + memset(&ifReq, 0, sizeof(struct ifreq)); + // set SNAP ID value + ifReq.ifr_ifru.snap_id = snapId; + + if(setdefaultif(&ifReq) == 0) { + // OK + error = 0; + return true; + } else { + error = errno; + return false; + } + +} + +static void qt_SaveIapName(QSettings& settings, QStringList& iapNames, QString& iapNameValue) { + if(iapNames.contains(iapNameValue) && iapNames.first() == iapNameValue) { + // no need to update + } else { + if(iapNameValue != QString("Easy WLAN")) { + // new selection alway on top + iapNames.removeAll(iapNameValue); + iapNames.prepend(iapNameValue); + writeIapNamesSettings(settings, iapNames); + } else { + // Unbeliveable ... if IAP dodn't exist before + // no matter what you choose from IAP selection list + // you will get "Easy WLAN" as IAP name value + + // somehow commsdb is not in sync + } + } +} + +static QString qt_OfferIapDialog() { + TBuf8<256> iapName; + + RSocketServ socketServ; + CleanupClosePushL(socketServ); + + RConnection connection; + CleanupClosePushL(connection); + + socketServ.Connect(); + connection.Open(socketServ); + connection.Start(); + + connection.GetDesSetting(TPtrC(KIapNameSetting), iapName); + + //connection.Stop(); + + iapName.ZeroTerminate(); + QString strIapName((char*)iapName.Ptr()); + + int error = 0; + if(!qt_SetDefaultIapName(strIapName, error)) { + //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); + strIapName = QString(""); + } + + CleanupStack::PopAndDestroy(&connection); + CleanupStack::PopAndDestroy(&socketServ); + + return strIapName; +} + +static QString qt_CheckForActiveConnection() { + TUint count; + + RSocketServ serv; + CleanupClosePushL(serv); + + RConnection conn; + CleanupClosePushL(conn); + + serv.Connect(); + conn.Open(serv); + + TConnectionInfoBuf connInfo; + + TBuf8<256> iapName; + TBuf8<256> iapServiceType; + + QString strIapName; + + if (conn.EnumerateConnections(count) == KErrNone) { + if(count > 0) { + for (TUint i = 1; i <= count; i++) { + if (conn.GetConnectionInfo(i, connInfo) == KErrNone) { + RConnection tempConn; + CleanupClosePushL(tempConn); + tempConn.Open(serv); + if (tempConn.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { + tempConn.GetDesSetting(TPtrC(KIapNameSetting), iapName); + tempConn.GetDesSetting(TPtrC(KIapServiceType), iapServiceType); + //tempConn.Stop(); + iapName.ZeroTerminate(); + iapServiceType.ZeroTerminate(); + +// if(iapServiceType.Find(_L8("LANService")) != KErrNotFound) { +// activeLanConnectionFound = ETrue; +// break; +// } + strIapName = QString((char*)iapName.Ptr()); + int error = 0; + if(!qt_SetDefaultIapName(strIapName, error)) { + //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); + strIapName = QString(""); + } + + CleanupStack::PopAndDestroy(&tempConn); + break; + } + } + } + } + } + + //conn.Stop(); + + CleanupStack::PopAndDestroy(&conn); + CleanupStack::PopAndDestroy(&serv); + + return strIapName; +} + +static QString qt_CheckSettingsForConnection(QStringList& iapNames) { + QString strIapName; + for(int index = 0; index < iapNames.size(); ++index) { + strIapName = iapNames.at(index); + int error = 0; + if(!qt_SetDefaultIapName(strIapName, error)) { + //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); + strIapName = QString(""); + } else { + return strIapName; + } + } + return strIapName; +} + +static void qt_SetDefaultIapL() +{ + // settings @ /c/data/.config/Trolltech.com + QSettings settings(QSettings::UserScope, qtOrganizationTag); + // populate iap name list + QStringList iapNames; + readIapNamesSettings(settings, iapNames); + + QString iapNameValue; + + iapNameValue = qt_CheckForActiveConnection(); + + if(!iapNameValue.isEmpty()) { + qt_SaveIapName(settings, iapNames, iapNameValue); + return; + } + + iapNameValue = qt_CheckSettingsForConnection(iapNames); + + if(!iapNameValue.isEmpty()) { + qt_SaveIapName(settings, iapNames, iapNameValue); + return; + } + + /* + * no active LAN connections yet + * no IAP in settings + * offer IAP dialog to user + */ + iapNameValue = qt_OfferIapDialog(); + qt_SaveIapName(settings, iapNames, iapNameValue); + return; + +} + +static int qt_SetDefaultIap() +{ + TRAPD(err1, qt_SetDefaultIapL()); +// TRAPD(err2, qt_InterfaceInfoL()); +// TRAPD(err3, qt_RouteInfoL()); + return err1; +} + +#endif // QSYM_IAP_UTIL_H diff --git a/examples/phonon/musicplayer/main.cpp b/examples/phonon/musicplayer/main.cpp deleted file mode 100644 index fc7baa3..0000000 --- a/examples/phonon/musicplayer/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include - -#include "mainwindow.h" - -//![1] -int main(int argv, char **args) -{ - QApplication app(argv, args); - app.setApplicationName("Music Player"); - app.setQuitOnLastWindowClosed(true); - - MainWindow window; - window.show(); - - return app.exec(); -} -//![1] diff --git a/examples/phonon/musicplayer/mainwindow.cpp b/examples/phonon/musicplayer/mainwindow.cpp deleted file mode 100644 index 787ae53..0000000 --- a/examples/phonon/musicplayer/mainwindow.cpp +++ /dev/null @@ -1,355 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -***************************************************************************/ - -#include - -#include "mainwindow.h" - -//![0] -MainWindow::MainWindow() -{ - audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); - mediaObject = new Phonon::MediaObject(this); - metaInformationResolver = new Phonon::MediaObject(this); - - mediaObject->setTickInterval(1000); -//![0] -//![2] - connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64))); - connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), - this, SLOT(stateChanged(Phonon::State, Phonon::State))); - connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State,Phonon::State)), - this, SLOT(metaStateChanged(Phonon::State, Phonon::State))); - connect(mediaObject, SIGNAL(currentSourceChanged(const Phonon::MediaSource &)), - this, SLOT(sourceChanged(const Phonon::MediaSource &))); - connect(mediaObject, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish())); -//![2] - -//![1] - Phonon::createPath(mediaObject, audioOutput); -//![1] - - setupActions(); - setupMenus(); - setupUi(); - timeLcd->display("00:00"); -} - -//![6] -void MainWindow::addFiles() -{ - QStringList files = QFileDialog::getOpenFileNames(this, tr("Select Music Files"), - QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); - - if (files.isEmpty()) - return; - - int index = sources.size(); - foreach (QString string, files) { - Phonon::MediaSource source(string); - - sources.append(source); - } - if (!sources.isEmpty()) - metaInformationResolver->setCurrentSource(sources.at(index)); - -} -//![6] - -void MainWindow::about() -{ - QMessageBox::information(this, tr("About Music Player"), - tr("The Music Player example shows how to use Phonon - the multimedia" - " framework that comes with Qt - to create a simple music player.")); -} - -//![9] -void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState */) -{ - switch (newState) { - case Phonon::ErrorState: - if (mediaObject->errorType() == Phonon::FatalError) { - QMessageBox::warning(this, tr("Fatal Error"), - mediaObject->errorString()); - } else { - QMessageBox::warning(this, tr("Error"), - mediaObject->errorString()); - } - break; -//![9] -//![10] - case Phonon::PlayingState: - playAction->setEnabled(false); - pauseAction->setEnabled(true); - stopAction->setEnabled(true); - break; - case Phonon::StoppedState: - stopAction->setEnabled(false); - playAction->setEnabled(true); - pauseAction->setEnabled(false); - timeLcd->display("00:00"); - break; - case Phonon::PausedState: - pauseAction->setEnabled(false); - stopAction->setEnabled(true); - playAction->setEnabled(true); - break; -//![10] - case Phonon::BufferingState: - break; - default: - ; - } -} - -//![11] -void MainWindow::tick(qint64 time) -{ - QTime displayTime(0, (time / 60000) % 60, (time / 1000) % 60); - - timeLcd->display(displayTime.toString("mm:ss")); -} -//![11] - -//![12] -void MainWindow::tableClicked(int row, int /* column */) -{ - bool wasPlaying = mediaObject->state() == Phonon::PlayingState; - - mediaObject->stop(); - mediaObject->clearQueue(); - - if (row >= sources.size()) - return; - - mediaObject->setCurrentSource(sources[row]); - - if (wasPlaying) - mediaObject->play(); - else - mediaObject->stop(); -} -//![12] - -//![13] -void MainWindow::sourceChanged(const Phonon::MediaSource &source) -{ - musicTable->selectRow(sources.indexOf(source)); - timeLcd->display("00:00"); -} -//![13] - -//![14] -void MainWindow::metaStateChanged(Phonon::State newState, Phonon::State /* oldState */) -{ - if (newState == Phonon::ErrorState) { - QMessageBox::warning(this, tr("Error opening files"), - metaInformationResolver->errorString()); - while (!sources.isEmpty() && - !(sources.takeLast() == metaInformationResolver->currentSource())) {} /* loop */; - return; - } - - if (newState != Phonon::StoppedState && newState != Phonon::PausedState) - return; - - if (metaInformationResolver->currentSource().type() == Phonon::MediaSource::Invalid) - return; - - QMap metaData = metaInformationResolver->metaData(); - - QString title = metaData.value("TITLE"); - if (title == "") - title = metaInformationResolver->currentSource().fileName(); - - QTableWidgetItem *titleItem = new QTableWidgetItem(title); - titleItem->setFlags(titleItem->flags() ^ Qt::ItemIsEditable); - QTableWidgetItem *artistItem = new QTableWidgetItem(metaData.value("ARTIST")); - artistItem->setFlags(artistItem->flags() ^ Qt::ItemIsEditable); - QTableWidgetItem *albumItem = new QTableWidgetItem(metaData.value("ALBUM")); - albumItem->setFlags(albumItem->flags() ^ Qt::ItemIsEditable); - QTableWidgetItem *yearItem = new QTableWidgetItem(metaData.value("DATE")); - yearItem->setFlags(yearItem->flags() ^ Qt::ItemIsEditable); -//![14] - - int currentRow = musicTable->rowCount(); - musicTable->insertRow(currentRow); - musicTable->setItem(currentRow, 0, titleItem); - musicTable->setItem(currentRow, 1, artistItem); - musicTable->setItem(currentRow, 2, albumItem); - musicTable->setItem(currentRow, 3, yearItem); - -//![15] - if (musicTable->selectedItems().isEmpty()) { - musicTable->selectRow(0); - mediaObject->setCurrentSource(metaInformationResolver->currentSource()); - } - - Phonon::MediaSource source = metaInformationResolver->currentSource(); - int index = sources.indexOf(metaInformationResolver->currentSource()) + 1; - if (sources.size() > index) { - metaInformationResolver->setCurrentSource(sources.at(index)); - } - else { - musicTable->resizeColumnsToContents(); - if (musicTable->columnWidth(0) > 300) - musicTable->setColumnWidth(0, 300); - } -} -//![15] - -//![16] -void MainWindow::aboutToFinish() -{ - int index = sources.indexOf(mediaObject->currentSource()) + 1; - if (sources.size() > index) { - mediaObject->enqueue(sources.at(index)); - } -} -//![16] - -void MainWindow::setupActions() -{ - playAction = new QAction(style()->standardIcon(QStyle::SP_MediaPlay), tr("Play"), this); - playAction->setShortcut(tr("Crl+P")); - playAction->setDisabled(true); - pauseAction = new QAction(style()->standardIcon(QStyle::SP_MediaPause), tr("Pause"), this); - pauseAction->setShortcut(tr("Ctrl+A")); - pauseAction->setDisabled(true); - stopAction = new QAction(style()->standardIcon(QStyle::SP_MediaStop), tr("Stop"), this); - stopAction->setShortcut(tr("Ctrl+S")); - stopAction->setDisabled(true); - nextAction = new QAction(style()->standardIcon(QStyle::SP_MediaSkipForward), tr("Next"), this); - nextAction->setShortcut(tr("Ctrl+N")); - previousAction = new QAction(style()->standardIcon(QStyle::SP_MediaSkipBackward), tr("Previous"), this); - previousAction->setShortcut(tr("Ctrl+R")); - addFilesAction = new QAction(tr("Add &Files"), this); - addFilesAction->setShortcut(tr("Ctrl+F")); - exitAction = new QAction(tr("E&xit"), this); - exitAction->setShortcuts(QKeySequence::Quit); - aboutAction = new QAction(tr("A&bout"), this); - aboutAction->setShortcut(tr("Ctrl+B")); - aboutQtAction = new QAction(tr("About &Qt"), this); - aboutQtAction->setShortcut(tr("Ctrl+Q")); - -//![5] - connect(playAction, SIGNAL(triggered()), mediaObject, SLOT(play())); - connect(pauseAction, SIGNAL(triggered()), mediaObject, SLOT(pause()) ); - connect(stopAction, SIGNAL(triggered()), mediaObject, SLOT(stop())); -//![5] - connect(addFilesAction, SIGNAL(triggered()), this, SLOT(addFiles())); - connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); - connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); - connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); -} - -void MainWindow::setupMenus() -{ - QMenu *fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(addFilesAction); - fileMenu->addSeparator(); - fileMenu->addAction(exitAction); - - QMenu *aboutMenu = menuBar()->addMenu(tr("&Help")); - aboutMenu->addAction(aboutAction); - aboutMenu->addAction(aboutQtAction); -} - -//![3] -void MainWindow::setupUi() -{ -//![3] - QToolBar *bar = new QToolBar; - - bar->addAction(playAction); - bar->addAction(pauseAction); - bar->addAction(stopAction); - -//![4] - seekSlider = new Phonon::SeekSlider(this); - seekSlider->setMediaObject(mediaObject); - - volumeSlider = new Phonon::VolumeSlider(this); - volumeSlider->setAudioOutput(audioOutput); -//![4] - volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); - - QLabel *volumeLabel = new QLabel; - volumeLabel->setPixmap(QPixmap("images/volume.png")); - - QPalette palette; - palette.setBrush(QPalette::Light, Qt::darkGray); - - timeLcd = new QLCDNumber; - timeLcd->setPalette(palette); - - QStringList headers; - headers << tr("Title") << tr("Artist") << tr("Album") << tr("Year"); - - musicTable = new QTableWidget(0, 4); - musicTable->setHorizontalHeaderLabels(headers); - musicTable->setSelectionMode(QAbstractItemView::SingleSelection); - musicTable->setSelectionBehavior(QAbstractItemView::SelectRows); - connect(musicTable, SIGNAL(cellPressed(int, int)), - this, SLOT(tableClicked(int, int))); - - QHBoxLayout *seekerLayout = new QHBoxLayout; - seekerLayout->addWidget(seekSlider); - seekerLayout->addWidget(timeLcd); - - QHBoxLayout *playbackLayout = new QHBoxLayout; - playbackLayout->addWidget(bar); - playbackLayout->addStretch(); - playbackLayout->addWidget(volumeLabel); - playbackLayout->addWidget(volumeSlider); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(musicTable); - mainLayout->addLayout(seekerLayout); - mainLayout->addLayout(playbackLayout); - - QWidget *widget = new QWidget; - widget->setLayout(mainLayout); - - setCentralWidget(widget); - setWindowTitle("Phonon Music Player"); -} - diff --git a/examples/phonon/musicplayer/mainwindow.h b/examples/phonon/musicplayer/mainwindow.h deleted file mode 100644 index 41f8147..0000000 --- a/examples/phonon/musicplayer/mainwindow.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QAction; -class QTableWidget; -class QLCDNumber; -QT_END_NAMESPACE - -//![0] - -class MainWindow : public QMainWindow -{ -//![0] - Q_OBJECT - -public: - MainWindow(); - - QSize sizeHint() const { - return QSize(500, 300); - } - -private slots: - void addFiles(); - void about(); -//![1] - void stateChanged(Phonon::State newState, Phonon::State oldState); - void tick(qint64 time); - void sourceChanged(const Phonon::MediaSource &source); - void metaStateChanged(Phonon::State newState, Phonon::State oldState); - void aboutToFinish(); - void tableClicked(int row, int column); -//![1] - -private: - void setupActions(); - void setupMenus(); - void setupUi(); - -//![2] - Phonon::SeekSlider *seekSlider; - Phonon::MediaObject *mediaObject; - Phonon::MediaObject *metaInformationResolver; - Phonon::AudioOutput *audioOutput; - Phonon::VolumeSlider *volumeSlider; - QList sources; -//![2] - - QAction *playAction; - QAction *pauseAction; - QAction *stopAction; - QAction *nextAction; - QAction *previousAction; - QAction *addFilesAction; - QAction *exitAction; - QAction *aboutAction; - QAction *aboutQtAction; - QLCDNumber *timeLcd; - QTableWidget *musicTable; -}; - -#endif diff --git a/examples/phonon/musicplayer/musicplayer.pro b/examples/phonon/musicplayer/musicplayer.pro deleted file mode 100644 index a0c953a..0000000 --- a/examples/phonon/musicplayer/musicplayer.pro +++ /dev/null @@ -1,17 +0,0 @@ -QT += phonon - -HEADERS += mainwindow.h -SOURCES += main.cpp \ - mainwindow.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/phonon/musicplayer -sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png images -sources.path = $$[QT_INSTALL_EXAMPLES]/phonon/musicplayer -INSTALLS += target sources - -wince*{ -DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout -} - -symbian:TARGET.UID3 = 0xA000CF6A diff --git a/examples/phonon/phonon.pro b/examples/phonon/phonon.pro index 0ddf767..aa6ac13 100644 --- a/examples/phonon/phonon.pro +++ b/examples/phonon/phonon.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS = musicplayer \ +SUBDIRS = qmusicplayer \ capabilities # install diff --git a/examples/phonon/qmusicplayer/main.cpp b/examples/phonon/qmusicplayer/main.cpp new file mode 100644 index 0000000..fc7baa3 --- /dev/null +++ b/examples/phonon/qmusicplayer/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include + +#include "mainwindow.h" + +//![1] +int main(int argv, char **args) +{ + QApplication app(argv, args); + app.setApplicationName("Music Player"); + app.setQuitOnLastWindowClosed(true); + + MainWindow window; + window.show(); + + return app.exec(); +} +//![1] diff --git a/examples/phonon/qmusicplayer/mainwindow.cpp b/examples/phonon/qmusicplayer/mainwindow.cpp new file mode 100644 index 0000000..787ae53 --- /dev/null +++ b/examples/phonon/qmusicplayer/mainwindow.cpp @@ -0,0 +1,355 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +***************************************************************************/ + +#include + +#include "mainwindow.h" + +//![0] +MainWindow::MainWindow() +{ + audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); + mediaObject = new Phonon::MediaObject(this); + metaInformationResolver = new Phonon::MediaObject(this); + + mediaObject->setTickInterval(1000); +//![0] +//![2] + connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64))); + connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), + this, SLOT(stateChanged(Phonon::State, Phonon::State))); + connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State,Phonon::State)), + this, SLOT(metaStateChanged(Phonon::State, Phonon::State))); + connect(mediaObject, SIGNAL(currentSourceChanged(const Phonon::MediaSource &)), + this, SLOT(sourceChanged(const Phonon::MediaSource &))); + connect(mediaObject, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish())); +//![2] + +//![1] + Phonon::createPath(mediaObject, audioOutput); +//![1] + + setupActions(); + setupMenus(); + setupUi(); + timeLcd->display("00:00"); +} + +//![6] +void MainWindow::addFiles() +{ + QStringList files = QFileDialog::getOpenFileNames(this, tr("Select Music Files"), + QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); + + if (files.isEmpty()) + return; + + int index = sources.size(); + foreach (QString string, files) { + Phonon::MediaSource source(string); + + sources.append(source); + } + if (!sources.isEmpty()) + metaInformationResolver->setCurrentSource(sources.at(index)); + +} +//![6] + +void MainWindow::about() +{ + QMessageBox::information(this, tr("About Music Player"), + tr("The Music Player example shows how to use Phonon - the multimedia" + " framework that comes with Qt - to create a simple music player.")); +} + +//![9] +void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState */) +{ + switch (newState) { + case Phonon::ErrorState: + if (mediaObject->errorType() == Phonon::FatalError) { + QMessageBox::warning(this, tr("Fatal Error"), + mediaObject->errorString()); + } else { + QMessageBox::warning(this, tr("Error"), + mediaObject->errorString()); + } + break; +//![9] +//![10] + case Phonon::PlayingState: + playAction->setEnabled(false); + pauseAction->setEnabled(true); + stopAction->setEnabled(true); + break; + case Phonon::StoppedState: + stopAction->setEnabled(false); + playAction->setEnabled(true); + pauseAction->setEnabled(false); + timeLcd->display("00:00"); + break; + case Phonon::PausedState: + pauseAction->setEnabled(false); + stopAction->setEnabled(true); + playAction->setEnabled(true); + break; +//![10] + case Phonon::BufferingState: + break; + default: + ; + } +} + +//![11] +void MainWindow::tick(qint64 time) +{ + QTime displayTime(0, (time / 60000) % 60, (time / 1000) % 60); + + timeLcd->display(displayTime.toString("mm:ss")); +} +//![11] + +//![12] +void MainWindow::tableClicked(int row, int /* column */) +{ + bool wasPlaying = mediaObject->state() == Phonon::PlayingState; + + mediaObject->stop(); + mediaObject->clearQueue(); + + if (row >= sources.size()) + return; + + mediaObject->setCurrentSource(sources[row]); + + if (wasPlaying) + mediaObject->play(); + else + mediaObject->stop(); +} +//![12] + +//![13] +void MainWindow::sourceChanged(const Phonon::MediaSource &source) +{ + musicTable->selectRow(sources.indexOf(source)); + timeLcd->display("00:00"); +} +//![13] + +//![14] +void MainWindow::metaStateChanged(Phonon::State newState, Phonon::State /* oldState */) +{ + if (newState == Phonon::ErrorState) { + QMessageBox::warning(this, tr("Error opening files"), + metaInformationResolver->errorString()); + while (!sources.isEmpty() && + !(sources.takeLast() == metaInformationResolver->currentSource())) {} /* loop */; + return; + } + + if (newState != Phonon::StoppedState && newState != Phonon::PausedState) + return; + + if (metaInformationResolver->currentSource().type() == Phonon::MediaSource::Invalid) + return; + + QMap metaData = metaInformationResolver->metaData(); + + QString title = metaData.value("TITLE"); + if (title == "") + title = metaInformationResolver->currentSource().fileName(); + + QTableWidgetItem *titleItem = new QTableWidgetItem(title); + titleItem->setFlags(titleItem->flags() ^ Qt::ItemIsEditable); + QTableWidgetItem *artistItem = new QTableWidgetItem(metaData.value("ARTIST")); + artistItem->setFlags(artistItem->flags() ^ Qt::ItemIsEditable); + QTableWidgetItem *albumItem = new QTableWidgetItem(metaData.value("ALBUM")); + albumItem->setFlags(albumItem->flags() ^ Qt::ItemIsEditable); + QTableWidgetItem *yearItem = new QTableWidgetItem(metaData.value("DATE")); + yearItem->setFlags(yearItem->flags() ^ Qt::ItemIsEditable); +//![14] + + int currentRow = musicTable->rowCount(); + musicTable->insertRow(currentRow); + musicTable->setItem(currentRow, 0, titleItem); + musicTable->setItem(currentRow, 1, artistItem); + musicTable->setItem(currentRow, 2, albumItem); + musicTable->setItem(currentRow, 3, yearItem); + +//![15] + if (musicTable->selectedItems().isEmpty()) { + musicTable->selectRow(0); + mediaObject->setCurrentSource(metaInformationResolver->currentSource()); + } + + Phonon::MediaSource source = metaInformationResolver->currentSource(); + int index = sources.indexOf(metaInformationResolver->currentSource()) + 1; + if (sources.size() > index) { + metaInformationResolver->setCurrentSource(sources.at(index)); + } + else { + musicTable->resizeColumnsToContents(); + if (musicTable->columnWidth(0) > 300) + musicTable->setColumnWidth(0, 300); + } +} +//![15] + +//![16] +void MainWindow::aboutToFinish() +{ + int index = sources.indexOf(mediaObject->currentSource()) + 1; + if (sources.size() > index) { + mediaObject->enqueue(sources.at(index)); + } +} +//![16] + +void MainWindow::setupActions() +{ + playAction = new QAction(style()->standardIcon(QStyle::SP_MediaPlay), tr("Play"), this); + playAction->setShortcut(tr("Crl+P")); + playAction->setDisabled(true); + pauseAction = new QAction(style()->standardIcon(QStyle::SP_MediaPause), tr("Pause"), this); + pauseAction->setShortcut(tr("Ctrl+A")); + pauseAction->setDisabled(true); + stopAction = new QAction(style()->standardIcon(QStyle::SP_MediaStop), tr("Stop"), this); + stopAction->setShortcut(tr("Ctrl+S")); + stopAction->setDisabled(true); + nextAction = new QAction(style()->standardIcon(QStyle::SP_MediaSkipForward), tr("Next"), this); + nextAction->setShortcut(tr("Ctrl+N")); + previousAction = new QAction(style()->standardIcon(QStyle::SP_MediaSkipBackward), tr("Previous"), this); + previousAction->setShortcut(tr("Ctrl+R")); + addFilesAction = new QAction(tr("Add &Files"), this); + addFilesAction->setShortcut(tr("Ctrl+F")); + exitAction = new QAction(tr("E&xit"), this); + exitAction->setShortcuts(QKeySequence::Quit); + aboutAction = new QAction(tr("A&bout"), this); + aboutAction->setShortcut(tr("Ctrl+B")); + aboutQtAction = new QAction(tr("About &Qt"), this); + aboutQtAction->setShortcut(tr("Ctrl+Q")); + +//![5] + connect(playAction, SIGNAL(triggered()), mediaObject, SLOT(play())); + connect(pauseAction, SIGNAL(triggered()), mediaObject, SLOT(pause()) ); + connect(stopAction, SIGNAL(triggered()), mediaObject, SLOT(stop())); +//![5] + connect(addFilesAction, SIGNAL(triggered()), this, SLOT(addFiles())); + connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); + connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); + connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); +} + +void MainWindow::setupMenus() +{ + QMenu *fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu->addAction(addFilesAction); + fileMenu->addSeparator(); + fileMenu->addAction(exitAction); + + QMenu *aboutMenu = menuBar()->addMenu(tr("&Help")); + aboutMenu->addAction(aboutAction); + aboutMenu->addAction(aboutQtAction); +} + +//![3] +void MainWindow::setupUi() +{ +//![3] + QToolBar *bar = new QToolBar; + + bar->addAction(playAction); + bar->addAction(pauseAction); + bar->addAction(stopAction); + +//![4] + seekSlider = new Phonon::SeekSlider(this); + seekSlider->setMediaObject(mediaObject); + + volumeSlider = new Phonon::VolumeSlider(this); + volumeSlider->setAudioOutput(audioOutput); +//![4] + volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); + + QLabel *volumeLabel = new QLabel; + volumeLabel->setPixmap(QPixmap("images/volume.png")); + + QPalette palette; + palette.setBrush(QPalette::Light, Qt::darkGray); + + timeLcd = new QLCDNumber; + timeLcd->setPalette(palette); + + QStringList headers; + headers << tr("Title") << tr("Artist") << tr("Album") << tr("Year"); + + musicTable = new QTableWidget(0, 4); + musicTable->setHorizontalHeaderLabels(headers); + musicTable->setSelectionMode(QAbstractItemView::SingleSelection); + musicTable->setSelectionBehavior(QAbstractItemView::SelectRows); + connect(musicTable, SIGNAL(cellPressed(int, int)), + this, SLOT(tableClicked(int, int))); + + QHBoxLayout *seekerLayout = new QHBoxLayout; + seekerLayout->addWidget(seekSlider); + seekerLayout->addWidget(timeLcd); + + QHBoxLayout *playbackLayout = new QHBoxLayout; + playbackLayout->addWidget(bar); + playbackLayout->addStretch(); + playbackLayout->addWidget(volumeLabel); + playbackLayout->addWidget(volumeSlider); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(musicTable); + mainLayout->addLayout(seekerLayout); + mainLayout->addLayout(playbackLayout); + + QWidget *widget = new QWidget; + widget->setLayout(mainLayout); + + setCentralWidget(widget); + setWindowTitle("Phonon Music Player"); +} + diff --git a/examples/phonon/qmusicplayer/mainwindow.h b/examples/phonon/qmusicplayer/mainwindow.h new file mode 100644 index 0000000..41f8147 --- /dev/null +++ b/examples/phonon/qmusicplayer/mainwindow.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QAction; +class QTableWidget; +class QLCDNumber; +QT_END_NAMESPACE + +//![0] + +class MainWindow : public QMainWindow +{ +//![0] + Q_OBJECT + +public: + MainWindow(); + + QSize sizeHint() const { + return QSize(500, 300); + } + +private slots: + void addFiles(); + void about(); +//![1] + void stateChanged(Phonon::State newState, Phonon::State oldState); + void tick(qint64 time); + void sourceChanged(const Phonon::MediaSource &source); + void metaStateChanged(Phonon::State newState, Phonon::State oldState); + void aboutToFinish(); + void tableClicked(int row, int column); +//![1] + +private: + void setupActions(); + void setupMenus(); + void setupUi(); + +//![2] + Phonon::SeekSlider *seekSlider; + Phonon::MediaObject *mediaObject; + Phonon::MediaObject *metaInformationResolver; + Phonon::AudioOutput *audioOutput; + Phonon::VolumeSlider *volumeSlider; + QList sources; +//![2] + + QAction *playAction; + QAction *pauseAction; + QAction *stopAction; + QAction *nextAction; + QAction *previousAction; + QAction *addFilesAction; + QAction *exitAction; + QAction *aboutAction; + QAction *aboutQtAction; + QLCDNumber *timeLcd; + QTableWidget *musicTable; +}; + +#endif diff --git a/examples/phonon/qmusicplayer/qmusicplayer.pro b/examples/phonon/qmusicplayer/qmusicplayer.pro new file mode 100644 index 0000000..25ab7eb --- /dev/null +++ b/examples/phonon/qmusicplayer/qmusicplayer.pro @@ -0,0 +1,17 @@ +QT += phonon + +HEADERS += mainwindow.h +SOURCES += main.cpp \ + mainwindow.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/phonon/qmusicplayer +sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png images +sources.path = $$[QT_INSTALL_EXAMPLES]/phonon/qmusicplayer +INSTALLS += target sources + +wince*{ +DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout +} + +symbian:TARGET.UID3 = 0xA000CF6A -- cgit v0.12 From d66df793b88f9ba924a1fefcec325d7c04af3ac3 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 9 Oct 2009 15:11:26 +0300 Subject: Fixed miscellaneous minor problems with Symbian docs. Reviewed-by: Espen Riskedal --- doc/src/howtos/exceptionsafety.qdoc | 8 ++++---- doc/src/platforms/platform-notes.qdoc | 4 +++- doc/src/platforms/s60-introduction.qdoc | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/src/howtos/exceptionsafety.qdoc b/doc/src/howtos/exceptionsafety.qdoc index 23bedf5..fa1427b 100644 --- a/doc/src/howtos/exceptionsafety.qdoc +++ b/doc/src/howtos/exceptionsafety.qdoc @@ -144,12 +144,12 @@ \section1 Platform-Specific Exception Handling - \section2 Symbian (Qt for S60) + \section2 The Symbian platform The Symbian platform implements its own exception system that differs from the standard - C++ mechanism. When using Qt for S60, and especially when writing code to access Symbian - functionality directly, it may be necessary to know about the underlying implementation - and how it interacts with Qt. + C++ mechanism. When using Qt for Symbian platform, and especially when writing code to + access Symbian functionality directly, it may be necessary to know about the underlying + implementation and how it interacts with Qt. The \l{Exception Safety with Symbian} document shows how to use the facilities provided by Qt to use exceptions as safely as possible. diff --git a/doc/src/platforms/platform-notes.qdoc b/doc/src/platforms/platform-notes.qdoc index 5be66f8..9896b08 100644 --- a/doc/src/platforms/platform-notes.qdoc +++ b/doc/src/platforms/platform-notes.qdoc @@ -67,6 +67,8 @@ \tableofcontents{1 Platform Notes - Windows} \o \l{Platform Notes - Mac OS X} \tableofcontents{1 Platform Notes - Mac OS X} + \o \l{Platform Notes - Symbian} + \tableofcontents{1 Platform Notes - Symbian} \o \l{Platform Notes - Embedded Linux} \tableofcontents{1 Platform Notes - Embedded Linux} \o \l{Platform Notes - Windows CE} @@ -409,7 +411,7 @@ to run on. More information about the combinations of platforms and compilers supported by Qt can be found on the \l{Supported Platforms} page. - For information about mixing exceptions with symbian leaves, + For information about mixing exceptions with Symbian leaves, see \l{Exception Safety with Symbian} \section1 Multimedia and Phonon Support diff --git a/doc/src/platforms/s60-introduction.qdoc b/doc/src/platforms/s60-introduction.qdoc index d145a82..d27eb39 100644 --- a/doc/src/platforms/s60-introduction.qdoc +++ b/doc/src/platforms/s60-introduction.qdoc @@ -122,8 +122,8 @@ build targets, as shown in the table below: \row \o \c QT_SIS_OPTIONS \o Options accepted by \c .sis creation. -i, install the package right away using PC suite. -c=, read certificate information from a file. - Execute \c{perl createpackage.pl} for more information - about options. + Execute \c{createpackage.pl} script without any + parameters for more information about options. By default no otions are given. \row \o \c QT_SIS_TARGET \o Target for which \c .sis file is created. Accepted values are build targets listed in -- cgit v0.12 From b7a780e057642b2829238cd8e83b812ea963f687 Mon Sep 17 00:00:00 2001 From: ninerider Date: Fri, 9 Oct 2009 14:31:03 +0200 Subject: All mousewheel tests skipped on Windows CE Due to more problems with this test, they are skipped alltogether on Windows CE. Reviewed-by: Joerg --- tests/auto/qtableview/tst_qtableview.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index bb0e226..55da180 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -3407,17 +3407,14 @@ void tst_QTableView::mouseWheel_data() void tst_QTableView::mouseWheel() { +#ifdef Q_OS_WINCE + QSKIP("Since different Windows CE versions sport different taskbars, we skip this test", SkipAll); +#endif QFETCH(int, scrollMode); QFETCH(int, delta); QFETCH(int, horizontalPositon); QFETCH(int, verticalPosition); - if (scrollMode == int(QAbstractItemView::ScrollPerPixel)) - { -#ifdef Q_OS_WINCE - QSKIP("Since different Windows CE versions sport different taskbars, we skip this test", SkipSingle); -#endif - } QtTestTableModel model(100, 100); QtTestTableView view; view.resize(500, 500); -- cgit v0.12 From 21a84b26028ec7f44c9c5c69fa17528e77e17174 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 9 Oct 2009 14:38:56 +0200 Subject: Doc: update known issues page (a little). --- doc/src/getting-started/known-issues.qdoc | 140 +++++++++++++----------------- 1 file changed, 62 insertions(+), 78 deletions(-) diff --git a/doc/src/getting-started/known-issues.qdoc b/doc/src/getting-started/known-issues.qdoc index 6f8eb66..40ac1c7 100644 --- a/doc/src/getting-started/known-issues.qdoc +++ b/doc/src/getting-started/known-issues.qdoc @@ -45,20 +45,72 @@ \ingroup platform-specific \brief A summary of known issues in Qt %VERSION% at the time of release. - An up-to-date list of known issues with Qt %VERSION% can be found via the - \l{Task Tracker} on the Qt website which provides additional information - about known issues and tasks related to Qt. + This page documents known problems with the packaging and installation in + Qt %VERSION%, as well as issues with third party software that we have + not been able to work around. For a list of such issues in previous Qt + versions refer to this page in the respective documentation. - \section1 General Issues + For a list list of known bugs in Qt %VERSION%, see the \l{Task Tracker} + on the Qt website. - When running Qt applications on Windows or with \c{-graphicssystem raster}, - any process that triggers a QWidget::update() from within a destructor - might result in a crash. + \section1 Installation Issues + \section2 Building the Source Package on Windows 7 + + \list + \o When building Qt 4.5.0 with Windows 7, the build fails with an error + message regarding failing to embed manifest. This a known issue with + Windows 7, explained in the Windows 7 SDK Beta + \l{http://download.microsoft.com/download/8/8/0/8808A472-6450-4723-9C87-977069714B27/ReleaseNotes.Htm} + {release notes}. A workaround for this issue is to patch the + \bold{embed_manifest_exe.prf} file with the following: + + \code + diff --git a/mkspecs/features/win32/embed_manifest_exe.prf b/mkspecs/features/win32/embed_manifest_exe.prf + index e1747f1..05f116e 100644 + --- a/mkspecs/features/win32/embed_manifest_exe.prf + +++ b/mkspecs/features/win32/embed_manifest_exe.prf + @@ -8,4 +8,9 @@ if(win32-msvc2005|win32-msvc2008):!equals(TEMPLATE_PREFIX, "vc"):equals(TEMPLATE + QMAKE_POST_LINK = $$quote(mt.exe -nologo -manifest \"$$replace(OBJECTS_DIR,/,\\)\\$${NOPATH_TARGET}.intermediate.ma + nifest\" -outputresource:$(DESTDIR_TARGET);1$$escape_expand(\n\t)) + QMAKE_POST_LINK += $$QMAKE_PREV_POST_LINK + QMAKE_CLEAN += \"$$replace(OBJECTS_DIR,/,\\)\\$${NOPATH_TARGET}.intermediate.manifest\" + + isEmpty(RC_FILE) { + + system("echo.>$$replace(OUT_PWD,/,\\)\\$$replace(OBJECTS_DIR,/,\\)\\Windows7WorkAround.rc") + + RC_FILE = $$replace(OUT_PWD,/,\\)\\$$replace(OBJECTS_DIR,/,\\)\\Windows7WorkAround.rc + + } + + + } + \endcode + + \section2 Installing the Source Package on Unix systems + + \o If you download a Zip source package, you will need to convert + Windows-style line endings (CR/LF) to Unix-style line-endings (LF) when + you uncompress the package. To do this, give the "-a" option when you + run the "unzip' command. + + If you fail to supply the "-a" option when unzipping the package, you + will see the following error message when you attempt to execute the + configure command: + "bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory" + \endlist + + \section2 Installing on Mac OS X 10.6 "Snow Leopard" + \list + \o Performing a new install of the Qt 4.6 beta on Snow Leopard + triggers a bug in the installer that causes the install to fail. + Updating an existing Qt installation works fine. + + There are two workarounds, either disable spotlight for the target + drive during the install, or do a custom install where you deselect + documentation and examples. Run the installer again as a full + install to get the documentation and examples installed. + \endlist \section1 Issues with Third Party Software - \section2 X11 Hardware Support + \section2 X11 \list \o There is a bug in the 169.xx NVIDIA drivers on certain GeForce 8 series @@ -76,7 +128,7 @@ of the drivers. \endlist - \section2 Windows Hardware Support + \section2 Windows \list \o When using version 6.14.11.6921 of the NVIDIA drivers for the GeForce @@ -85,43 +137,6 @@ applications that use OpenGL. This problem can be worked around by reducing the level of graphics acceleration provided by the driver, or by disabling hardware acceleration completely. - \endlist - - \section2 Windows Software Issues - - \list - - \o When building Qt 4.5.0 with Windows 7, the build fails with an error - message regarding failing to embed manifest. This a known issue with - Windows 7, explained in the Windows 7 SDK Beta - \l{http://download.microsoft.com/download/8/8/0/8808A472-6450-4723-9C87-977069714B27/ReleaseNotes.Htm} - {release notes}. A workaround for this issue is to patch the - \bold{embed_manifest_exe.prf} file with the following: - - \code - diff --git a/mkspecs/features/win32/embed_manifest_exe.prf b/mkspecs/features/win32/embed_manifest_exe.prf - index e1747f1..05f116e 100644 - --- a/mkspecs/features/win32/embed_manifest_exe.prf - +++ b/mkspecs/features/win32/embed_manifest_exe.prf - @@ -8,4 +8,9 @@ if(win32-msvc2005|win32-msvc2008):!equals(TEMPLATE_PREFIX, "vc"):equals(TEMPLATE - QMAKE_POST_LINK = $$quote(mt.exe -nologo -manifest \"$$replace(OBJECTS_DIR,/,\\)\\$${NOPATH_TARGET}.intermediate.ma - nifest\" -outputresource:$(DESTDIR_TARGET);1$$escape_expand(\n\t)) - QMAKE_POST_LINK += $$QMAKE_PREV_POST_LINK - QMAKE_CLEAN += \"$$replace(OBJECTS_DIR,/,\\)\\$${NOPATH_TARGET}.intermediate.manifest\" - + isEmpty(RC_FILE) { - + system("echo.>$$replace(OUT_PWD,/,\\)\\$$replace(OBJECTS_DIR,/,\\)\\Windows7WorkAround.rc") - + RC_FILE = $$replace(OUT_PWD,/,\\)\\$$replace(OBJECTS_DIR,/,\\)\\Windows7WorkAround.rc - + } - + - } - \en